···11source 'https://rubygems.org'
2233# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
44-ruby '2.7.4'
44+ruby File.read(File.join(__dir__, '.ruby-version')).strip
5566-gem 'cocoapods', '~> 1.11', '>= 1.11.2'
66+gem 'cocoapods', '~> 1.11', '>= 1.11.3'
···11-# To learn about Buck see [Docs](https://buckbuild.com/).
22-# To run your application with Buck:
33-# - install Buck
44-# - `npm start` - to start the packager
55-# - `cd android`
66-# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
77-# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
88-# - `buck install -r android/app` - compile, install and run application
99-#
1010-1111-load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
1212-1313-lib_deps = []
1414-1515-create_aar_targets(glob(["libs/*.aar"]))
1616-1717-create_jar_targets(glob(["libs/*.jar"]))
1818-1919-android_library(
2020- name = "all-libs",
2121- exported_deps = lib_deps,
2222-)
2323-2424-android_library(
2525- name = "app-code",
2626- srcs = glob([
2727- "src/main/java/**/*.java",
2828- ]),
2929- deps = [
3030- ":all-libs",
3131- ":build_config",
3232- ":res",
3333- ],
3434-)
3535-3636-android_build_config(
3737- name = "build_config",
3838- package = "xyz.blueskyweb.app",
3939-)
4040-4141-android_resource(
4242- name = "res",
4343- package = "xyz.blueskyweb.app",
4444- res = "src/main/res",
4545-)
4646-4747-android_binary(
4848- name = "app",
4949- keystore = "//android/keystores:debug",
5050- manifest = "src/main/AndroidManifest.xml",
5151- package_type = "debug",
5252- deps = [
5353- ":app-code",
5454- ],
5555-)
+62-213
android/app/build.gradle
···11apply plugin: "com.android.application"
22+apply plugin: "com.facebook.react"
2334import com.android.build.OutputFile
45import org.apache.tools.ant.taskdefs.condition.Os
5667/**
77- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
88- * and bundleReleaseJsAndAssets).
99- * These basically call `react-native bundle` with the correct arguments during the Android build
1010- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
1111- * bundle directly from the development server. Below you can see all the possible configurations
1212- * and their defaults. If you decide to add a configuration block, make sure to add it before the
1313- * `apply from: "../../node_modules/react-native/react.gradle"` line.
1414- *
1515- * project.ext.react = [
1616- * // the name of the generated asset file containing your JS bundle
1717- * bundleAssetName: "index.android.bundle",
1818- *
1919- * // the entry file for bundle generation. If none specified and
2020- * // "index.android.js" exists, it will be used. Otherwise "index.js" is
2121- * // default. Can be overridden with ENTRY_FILE environment variable.
2222- * entryFile: "index.android.js",
2323- *
2424- * // https://reactnative.dev/docs/performance#enable-the-ram-format
2525- * bundleCommand: "ram-bundle",
2626- *
2727- * // whether to bundle JS and assets in debug mode
2828- * bundleInDebug: false,
2929- *
3030- * // whether to bundle JS and assets in release mode
3131- * bundleInRelease: true,
3232- *
3333- * // whether to bundle JS and assets in another build variant (if configured).
3434- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
3535- * // The configuration property can be in the following formats
3636- * // 'bundleIn${productFlavor}${buildType}'
3737- * // 'bundleIn${buildType}'
3838- * // bundleInFreeDebug: true,
3939- * // bundleInPaidRelease: true,
4040- * // bundleInBeta: true,
4141- *
4242- * // whether to disable dev mode in custom build variants (by default only disabled in release)
4343- * // for example: to disable dev mode in the staging build type (if configured)
4444- * devDisabledInStaging: true,
4545- * // The configuration property can be in the following formats
4646- * // 'devDisabledIn${productFlavor}${buildType}'
4747- * // 'devDisabledIn${buildType}'
4848- *
4949- * // the root of your project, i.e. where "package.json" lives
5050- * root: "../../",
5151- *
5252- * // where to put the JS bundle asset in debug mode
5353- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
5454- *
5555- * // where to put the JS bundle asset in release mode
5656- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
5757- *
5858- * // where to put drawable resources / React Native assets, e.g. the ones you use via
5959- * // require('./image.png')), in debug mode
6060- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
6161- *
6262- * // where to put drawable resources / React Native assets, e.g. the ones you use via
6363- * // require('./image.png')), in release mode
6464- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
6565- *
6666- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
6767- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
6868- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
6969- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
7070- * // for example, you might want to remove it from here.
7171- * inputExcludes: ["android/**", "ios/**"],
7272- *
7373- * // override which node gets called and with what additional arguments
7474- * nodeExecutableAndArgs: ["node"],
7575- *
7676- * // supply additional arguments to the packager
7777- * extraPackagerArgs: []
7878- * ]
88+ * This is the configuration block to customize your React Native Android app.
99+ * By default you don't need to apply any configuration, just uncomment the lines you need.
7910 */
80118181-project.ext.react = [
8282- enableHermes: false, // clean and rebuild if changing
8383-]
8484-8585-apply from: "../../node_modules/react-native/react.gradle"
1212+react {
1313+ /* Folders */
1414+ // The root of your project, i.e. where "package.json" lives. Default is '..'
1515+ // root = file("../")
1616+ // The folder where the react-native NPM package is. Default is ../node_modules/react-native
1717+ // reactNativeDir = file("../node-modules/react-native")
1818+ // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
1919+ // codegenDir = file("../node-modules/react-native-codegen")
2020+ // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
2121+ // cliFile = file("../node_modules/react-native/cli.js")
2222+ /* Variants */
2323+ // The list of variants to that are debuggable. For those we're going to
2424+ // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
2525+ // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
2626+ // debuggableVariants = ["liteDebug", "prodDebug"]
2727+ /* Bundling */
2828+ // A list containing the node command and its flags. Default is just 'node'.
2929+ // nodeExecutableAndArgs = ["node"]
3030+ //
3131+ // The command to run when bundling. By default is 'bundle'
3232+ // bundleCommand = "ram-bundle"
3333+ //
3434+ // The path to the CLI configuration file. Default is empty.
3535+ // bundleConfig = file(../rn-cli.config.js)
3636+ //
3737+ // The name of the generated asset file containing your JS bundle
3838+ // bundleAssetName = "MyApplication.android.bundle"
3939+ //
4040+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
4141+ // entryFile = file("../js/MyApplication.android.js")
4242+ //
4343+ // A list of extra flags to pass to the 'bundle' commands.
4444+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
4545+ // extraPackagerArgs = []
4646+ /* Hermes Commands */
4747+ // The hermes compiler command to run. By default it is 'hermesc'
4848+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
4949+ //
5050+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
5151+ // hermesFlags = ["-O", "-output-source-map"]
5252+}
86538754/**
8888- * Set this to true to create two separate APKs instead of one:
8989- * - An APK that only works on ARM devices
9090- * - An APK that only works on x86 devices
9191- * The advantage is the size of the APK is reduced by about 4MB.
9292- * Upload all the APKs to the Play Store and people will download
9393- * the correct one based on the CPU architecture of their device.
5555+ * Set this to true to create four separate APKs instead of one,
5656+ * one for each native architecture. This is useful if you don't
5757+ * use App Bundles (https://developer.android.com/guide/app-bundle/)
5858+ * and want to have separate APKs to upload to the Play Store.
9459 */
9560def enableSeparateBuildPerCPUArchitecture = false
96619762/**
9898- * Run Proguard to shrink the Java bytecode in release builds.
6363+ * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
9964 */
10065def enableProguardInReleaseBuilds = false
1016610267/**
103103- * The preferred build flavor of JavaScriptCore.
6868+ * The preferred build flavor of JavaScriptCore (JSC)
10469 *
10570 * For example, to use the international variant, you can use:
10671 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
10772 *
10873 * The international variant includes ICU i18n library and necessary data
10974 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
110110- * give correct results when using with locales other than en-US. Note that
7575+ * give correct results when using with locales other than en-US. Note that
11176 * this variant is about 6MiB larger per architecture than default.
11277 */
11378def jscFlavor = 'org.webkit:android-jsc:+'
1147911580/**
116116- * Whether to enable the Hermes VM.
117117- *
118118- * This should be set on project.ext.react and that value will be read here. If it is not set
119119- * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120120- * and the benefits of using Hermes will therefore be sharply reduced.
121121- */
122122-def enableHermes = project.ext.react.get("enableHermes", false);
123123-124124-/**
125125- * Architectures to build native code for.
8181+ * Private function to get the list of Native Architectures you want to build.
8282+ * This reads the value from reactNativeArchitectures in your gradle.properties
8383+ * file and works together with the --active-arch-only flag of react-native run-android.
12684 */
12785def reactNativeArchitectures() {
12886 def value = project.getProperties().get("reactNativeArchitectures")
···1349213593 compileSdkVersion rootProject.ext.compileSdkVersion
136949595+ namespace "xyz.blueskyweb.app"
13796 defaultConfig {
13897 applicationId "xyz.blueskyweb.app"
13998 minSdkVersion rootProject.ext.minSdkVersion
14099 targetSdkVersion rootProject.ext.targetSdkVersion
141100 versionCode 1
142101 versionName "1.0"
143143- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144144-145145- if (isNewArchitectureEnabled()) {
146146- // We configure the NDK build only if you decide to opt-in for the New Architecture.
147147- externalNativeBuild {
148148- ndkBuild {
149149- arguments "APP_PLATFORM=android-21",
150150- "APP_STL=c++_shared",
151151- "NDK_TOOLCHAIN_VERSION=clang",
152152- "GENERATED_SRC_DIR=$buildDir/generated/source",
153153- "PROJECT_BUILD_DIR=$buildDir",
154154- "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
155155- "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
156156- cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157157- cppFlags "-std=c++17"
158158- // Make sure this target name is the same you specify inside the
159159- // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160160- targets "app_appmodules"
161161-162162- // Fix for windows limit on number of character in file paths and in command lines
163163- if (Os.isFamily(Os.FAMILY_WINDOWS)) {
164164- arguments "NDK_APP_SHORT_COMMANDS=true"
165165- }
166166- }
167167- }
168168- if (!enableSeparateBuildPerCPUArchitecture) {
169169- ndk {
170170- abiFilters (*reactNativeArchitectures())
171171- }
172172- }
173173- }
174174- }
175175-176176- if (isNewArchitectureEnabled()) {
177177- // We configure the NDK build only if you decide to opt-in for the New Architecture.
178178- externalNativeBuild {
179179- ndkBuild {
180180- path "$projectDir/src/main/jni/Android.mk"
181181- }
182182- }
183183- def reactAndroidProjectDir = project(':ReactAndroid').projectDir
184184- def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
185185- dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
186186- from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
187187- into("$buildDir/react-ndk/exported")
188188- }
189189- def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
190190- dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
191191- from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
192192- into("$buildDir/react-ndk/exported")
193193- }
194194- afterEvaluate {
195195- // If you wish to add a custom TurboModule or component locally,
196196- // you should uncomment this line.
197197- // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
198198- preDebugBuild.dependsOn(packageReactNdkDebugLibs)
199199- preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
200200-201201- // Due to a bug inside AGP, we have to explicitly set a dependency
202202- // between configureNdkBuild* tasks and the preBuild tasks.
203203- // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
204204- configureNdkBuildRelease.dependsOn(preReleaseBuild)
205205- configureNdkBuildDebug.dependsOn(preDebugBuild)
206206- reactNativeArchitectures().each { architecture ->
207207- tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
208208- dependsOn("preDebugBuild")
209209- }
210210- tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
211211- dependsOn("preReleaseBuild")
212212- }
213213- }
214214- }
215102 }
216103217104 splits {
···261148}
262149263150dependencies {
264264- implementation fileTree(dir: "libs", include: ["*.jar"])
151151+ // The version of react-native is set by the React Native Gradle Plugin
152152+ implementation("com.facebook.react:react-android")
265153266266- //noinspection GradleDynamicVersion
267267- implementation "com.facebook.react:react-native:+" // From node_modules
268268-269269- implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
154154+ implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
270155271156 implementation project(':rn-fetch-blob')
272157273273- debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
274274- exclude group:'com.facebook.fbjni'
275275- }
276276-158158+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
277159 debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
278278- exclude group:'com.facebook.flipper'
279160 exclude group:'com.squareup.okhttp3', module:'okhttp'
280161 }
281162282282- debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
283283- exclude group:'com.facebook.flipper'
284284- }
285285-286286- if (enableHermes) {
287287- def hermesPath = "../../node_modules/hermes-engine/android/";
288288- debugImplementation files(hermesPath + "hermes-debug.aar")
289289- releaseImplementation files(hermesPath + "hermes-release.aar")
163163+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
164164+ if (hermesEnabled.toBoolean()) {
165165+ implementation("com.facebook.react:hermes-android")
290166 } else {
291167 implementation jscFlavor
292168 }
293169}
294170295295-if (isNewArchitectureEnabled()) {
296296- // If new architecture is enabled, we let you build RN from source
297297- // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
298298- // This will be applied to all the imported transtitive dependency.
299299- configurations.all {
300300- resolutionStrategy.dependencySubstitution {
301301- substitute(module("com.facebook.react:react-native"))
302302- .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
303303- }
304304- }
305305-}
306306-307307-// Run this once to be able to run the application with BUCK
308308-// puts all compile dependencies into folder libs for BUCK to use
309309-task copyDownloadableDepsToLibs(type: Copy) {
310310- from configurations.implementation
311311- into 'libs'
312312-}
313313-314171apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
315315-316316-def isNewArchitectureEnabled() {
317317- // To opt-in for the New Architecture, you can either:
318318- // - Set `newArchEnabled` to true inside the `gradle.properties` file
319319- // - Invoke gradle with `-newArchEnabled=true`
320320- // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
321321- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
322322-}
-19
android/app/build_defs.bzl
···11-"""Helper definitions to glob .aar and .jar targets"""
22-33-def create_aar_targets(aarfiles):
44- for aarfile in aarfiles:
55- name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
66- lib_deps.append(":" + name)
77- android_prebuilt_aar(
88- name = name,
99- aar = aarfile,
1010- )
1111-1212-def create_jar_targets(jarfiles):
1313- for jarfile in jarfiles:
1414- name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
1515- lib_deps.append(":" + name)
1616- prebuilt_jar(
1717- name = name,
1818- binary_jar = jarfile,
1919- )
···2525import com.facebook.react.modules.network.NetworkingModule;
2626import okhttp3.OkHttpClient;
27272828+/**
2929+ * Class responsible of loading Flipper inside your React Native application. This is the debug
3030+ * flavor of it. Here you can add your own plugins and customize the Flipper setup.
3131+ */
2832public class ReactNativeFlipper {
2933 public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
3034 if (FlipperUtils.shouldEnableFlipper(context)) {
3135 final FlipperClient client = AndroidFlipperClient.getInstance(context);
32363337 client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
3434- client.addPlugin(new ReactFlipperPlugin());
3538 client.addPlugin(new DatabasesFlipperPlugin(context));
3639 client.addPlugin(new SharedPreferencesFlipperPlugin(context));
3740 client.addPlugin(CrashReporterPlugin.getInstance());
···2233import com.facebook.react.ReactActivity;
44import com.facebook.react.ReactActivityDelegate;
55-import com.facebook.react.ReactRootView;
55+import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
66+import com.facebook.react.defaults.DefaultReactActivityDelegate;
67import android.os.Bundle;
7889public class MainActivity extends ReactActivity {
···1718 }
18191920 /**
2020- * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
2121- * you can specify the rendered you wish to use (Fabric or the older renderer).
2121+ * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
2222+ * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
2323+ * (aka React 18) with two boolean flags.
2224 */
2325 @Override
2426 protected ReactActivityDelegate createReactActivityDelegate() {
2525- return new MainActivityDelegate(this, getMainComponentName());
2626- }
2727-2828- public static class MainActivityDelegate extends ReactActivityDelegate {
2929- public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
3030- super(activity, mainComponentName);
3131- }
3232-3333- @Override
3434- protected ReactRootView createRootView() {
3535- ReactRootView reactRootView = new ReactRootView(getContext());
2727+ return new DefaultReactActivityDelegate(
2828+ this,
2929+ getMainComponentName(),
3630 // If you opted-in for the New Architecture, we enable the Fabric Renderer.
3737- reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
3838- return reactRootView;
3939- }
4040-4141- @Override
4242- protected void onCreate(Bundle savedInstanceState) {
4343- super.onCreate(null);
4444- }
3131+ DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
3232+ // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
3333+ DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
3434+ );
4535 }
4636}
···11-package xyz.blueskyweb.app.newarchitecture;
22-33-import android.app.Application;
44-import androidx.annotation.NonNull;
55-import com.facebook.react.PackageList;
66-import com.facebook.react.ReactInstanceManager;
77-import com.facebook.react.ReactNativeHost;
88-import com.facebook.react.ReactPackage;
99-import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
1010-import com.facebook.react.bridge.JSIModulePackage;
1111-import com.facebook.react.bridge.JSIModuleProvider;
1212-import com.facebook.react.bridge.JSIModuleSpec;
1313-import com.facebook.react.bridge.JSIModuleType;
1414-import com.facebook.react.bridge.JavaScriptContextHolder;
1515-import com.facebook.react.bridge.ReactApplicationContext;
1616-import com.facebook.react.bridge.UIManager;
1717-import com.facebook.react.fabric.ComponentFactory;
1818-import com.facebook.react.fabric.CoreComponentsRegistry;
1919-import com.facebook.react.fabric.EmptyReactNativeConfig;
2020-import com.facebook.react.fabric.FabricJSIModuleProvider;
2121-import com.facebook.react.uimanager.ViewManagerRegistry;
2222-import xyz.blueskyweb.app.BuildConfig;
2323-import xyz.blueskyweb.app.newarchitecture.components.MainComponentsRegistry;
2424-import xyz.blueskyweb.app.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
2525-import java.util.ArrayList;
2626-import java.util.List;
2727-2828-/**
2929- * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
3030- * TurboModule delegates and the Fabric Renderer.
3131- *
3232- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
3333- * `newArchEnabled` property). Is ignored otherwise.
3434- */
3535-public class MainApplicationReactNativeHost extends ReactNativeHost {
3636- public MainApplicationReactNativeHost(Application application) {
3737- super(application);
3838- }
3939-4040- @Override
4141- public boolean getUseDeveloperSupport() {
4242- return BuildConfig.DEBUG;
4343- }
4444-4545- @Override
4646- protected List<ReactPackage> getPackages() {
4747- List<ReactPackage> packages = new PackageList(this).getPackages();
4848- // Packages that cannot be autolinked yet can be added manually here, for example:
4949- // packages.add(new MyReactNativePackage());
5050- // TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
5151- // packages.add(new TurboReactPackage() { ... });
5252- // If you have custom Fabric Components, their ViewManagers should also be loaded here
5353- // inside a ReactPackage.
5454- return packages;
5555- }
5656-5757- @Override
5858- protected String getJSMainModuleName() {
5959- return "index";
6060- }
6161-6262- @NonNull
6363- @Override
6464- protected ReactPackageTurboModuleManagerDelegate.Builder
6565- getReactPackageTurboModuleManagerDelegateBuilder() {
6666- // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
6767- // for the new architecture and to use TurboModules correctly.
6868- return new MainApplicationTurboModuleManagerDelegate.Builder();
6969- }
7070-7171- @Override
7272- protected JSIModulePackage getJSIModulePackage() {
7373- return new JSIModulePackage() {
7474- @Override
7575- public List<JSIModuleSpec> getJSIModules(
7676- final ReactApplicationContext reactApplicationContext,
7777- final JavaScriptContextHolder jsContext) {
7878- final List<JSIModuleSpec> specs = new ArrayList<>();
7979-8080- // Here we provide a new JSIModuleSpec that will be responsible of providing the
8181- // custom Fabric Components.
8282- specs.add(
8383- new JSIModuleSpec() {
8484- @Override
8585- public JSIModuleType getJSIModuleType() {
8686- return JSIModuleType.UIManager;
8787- }
8888-8989- @Override
9090- public JSIModuleProvider<UIManager> getJSIModuleProvider() {
9191- final ComponentFactory componentFactory = new ComponentFactory();
9292- CoreComponentsRegistry.register(componentFactory);
9393-9494- // Here we register a Components Registry.
9595- // The one that is generated with the template contains no components
9696- // and just provides you the one from React Native core.
9797- MainComponentsRegistry.register(componentFactory);
9898-9999- final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
100100-101101- ViewManagerRegistry viewManagerRegistry =
102102- new ViewManagerRegistry(
103103- reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
104104-105105- return new FabricJSIModuleProvider(
106106- reactApplicationContext,
107107- componentFactory,
108108- new EmptyReactNativeConfig(),
109109- viewManagerRegistry);
110110- }
111111- });
112112- return specs;
113113- }
114114- };
115115- }
116116-}
···11-package xyz.blueskyweb.app.newarchitecture.components;
22-33-import com.facebook.jni.HybridData;
44-import com.facebook.proguard.annotations.DoNotStrip;
55-import com.facebook.react.fabric.ComponentFactory;
66-import com.facebook.soloader.SoLoader;
77-88-/**
99- * Class responsible to load the custom Fabric Components. This class has native methods and needs a
1010- * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
1111- * folder for you).
1212- *
1313- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
1414- * `newArchEnabled` property). Is ignored otherwise.
1515- */
1616-@DoNotStrip
1717-public class MainComponentsRegistry {
1818- static {
1919- SoLoader.loadLibrary("fabricjni");
2020- }
2121-2222- @DoNotStrip private final HybridData mHybridData;
2323-2424- @DoNotStrip
2525- private native HybridData initHybrid(ComponentFactory componentFactory);
2626-2727- @DoNotStrip
2828- private MainComponentsRegistry(ComponentFactory componentFactory) {
2929- mHybridData = initHybrid(componentFactory);
3030- }
3131-3232- @DoNotStrip
3333- public static MainComponentsRegistry register(ComponentFactory componentFactory) {
3434- return new MainComponentsRegistry(componentFactory);
3535- }
3636-}
···11-package xyz.blueskyweb.app.newarchitecture.modules;
22-33-import com.facebook.jni.HybridData;
44-import com.facebook.react.ReactPackage;
55-import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
66-import com.facebook.react.bridge.ReactApplicationContext;
77-import com.facebook.soloader.SoLoader;
88-import java.util.List;
99-1010-/**
1111- * Class responsible to load the TurboModules. This class has native methods and needs a
1212- * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
1313- * folder for you).
1414- *
1515- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
1616- * `newArchEnabled` property). Is ignored otherwise.
1717- */
1818-public class MainApplicationTurboModuleManagerDelegate
1919- extends ReactPackageTurboModuleManagerDelegate {
2020-2121- private static volatile boolean sIsSoLibraryLoaded;
2222-2323- protected MainApplicationTurboModuleManagerDelegate(
2424- ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
2525- super(reactApplicationContext, packages);
2626- }
2727-2828- protected native HybridData initHybrid();
2929-3030- native boolean canCreateTurboModule(String moduleName);
3131-3232- public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
3333- protected MainApplicationTurboModuleManagerDelegate build(
3434- ReactApplicationContext context, List<ReactPackage> packages) {
3535- return new MainApplicationTurboModuleManagerDelegate(context, packages);
3636- }
3737- }
3838-3939- @Override
4040- protected synchronized void maybeLoadOtherSoLibraries() {
4141- if (!sIsSoLibraryLoaded) {
4242- // If you change the name of your application .so file in the Android.mk file,
4343- // make sure you update the name here as well.
4444- SoLoader.loadLibrary("app_appmodules");
4545- sIsSoLibraryLoaded = true;
4646- }
4747- }
4848-}
···11-#include "MainApplicationModuleProvider.h"
22-33-#include <rncore.h>
44-55-namespace facebook {
66-namespace react {
77-88-std::shared_ptr<TurboModule> MainApplicationModuleProvider(
99- const std::string moduleName,
1010- const JavaTurboModule::InitParams ¶ms) {
1111- // Here you can provide your own module provider for TurboModules coming from
1212- // either your application or from external libraries. The approach to follow
1313- // is similar to the following (for a library called `samplelibrary`:
1414- //
1515- // auto module = samplelibrary_ModuleProvider(moduleName, params);
1616- // if (module != nullptr) {
1717- // return module;
1818- // }
1919- // return rncore_ModuleProvider(moduleName, params);
2020- return rncore_ModuleProvider(moduleName, params);
2121-}
2222-2323-} // namespace react
2424-} // namespace facebook
···11+/**
22+ * Copyright (c) Meta Platforms, Inc. and affiliates.
33+ *
44+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
55+ * directory of this source tree.
66+ */
77+package xyz.blueskyweb.app;
88+import android.content.Context;
99+import com.facebook.react.ReactInstanceManager;
1010+/**
1111+ * Class responsible of loading Flipper inside your React Native application. This is the release
1212+ * flavor of it so it's empty as we don't want to load Flipper.
1313+ */
1414+public class ReactNativeFlipper {
1515+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
1616+ // Do nothing as we don't want to initialize Flipper on Release.
1717+ }
1818+}
+3-34
android/build.gradle
···99 compileSdkVersion = 33
1010 targetSdkVersion = 33
11111212- if (System.properties['os.arch'] == "aarch64") {
1313- // For M1 Users we need to use the NDK 24 which added support for aarch64
1414- ndkVersion = "24.0.8215888"
1515- } else {
1616- // Otherwise we default to the side-by-side NDK version from AGP.
1717- ndkVersion = "21.4.7075529"
1818- }
1212+ // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
1313+ ndkVersion = "23.1.7779620"
1914 }
2015 repositories {
2116 google()
2217 mavenCentral()
2318 }
2419 dependencies {
2525- classpath('com.android.tools.build:gradle:7.2.1')
2020+ classpath("com.android.tools.build:gradle:7.3.1")
2621 classpath("com.facebook.react:react-native-gradle-plugin")
2727- classpath("de.undercouch:gradle-download-task:4.1.2")
2828- // NOTE: Do not place your application dependencies here; they belong
2929- // in the individual module build.gradle files
3030- }
3131-}
3232-3333-allprojects {
3434- repositories {
3535- maven {
3636- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
3737- url("$rootDir/../node_modules/react-native/android")
3838- }
3939- maven {
4040- // Android JSC is installed from npm
4141- url("$rootDir/../node_modules/jsc-android/dist")
4242- }
4343- mavenCentral {
4444- // We don't want to fetch react-native from Maven Central as there are
4545- // older versions over there.
4646- content {
4747- excludeGroup "com.facebook.react"
4848- }
4949- }
5050- google()
5151- maven { url 'https://www.jitpack.io' }
5252- maven { url 'https://maven.google.com' }
5322 }
5423}
+4
android/gradle.properties
···3838# to write custom TurboModules/Fabric components OR use libraries that
3939# are providing them.
4040newArchEnabled=false
4141+4242+# Use this property to enable or disable the Hermes JS engine.
4343+# If set to false, you will be using JSC instead.
4444+hermesEnabled=true
···11+# This `.xcode.env` file is versioned and is used to source the environment
22+# used when running script phases inside Xcode.
33+# To customize your local environment, you can create an `.xcode.env.local`
44+# file that is not versioned.
55+# NODE_BINARY variable contains the PATH to the node executable.
66+#
77+# Customize the NODE_BINARY variable here.
88+# For example, to use nvm with brew, add the following line
99+# . "$(brew --prefix nvm)/nvm.sh" --no-use
1010+export NODE_BINARY=$(command -v node)
+24-10
ios/Podfile
···11require_relative '../node_modules/react-native/scripts/react_native_pods'
22require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3344-platform :ios, '11.0'
55-install! 'cocoapods', :deterministic_uuids => false
44+platform :ios, min_ios_version_supported
55+prepare_react_native_project!
66+77+flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
88+99+linkage = ENV['USE_FRAMEWORKS']
1010+if linkage != nil
1111+ Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
1212+ use_frameworks! :linkage => linkage.to_sym
1313+end
614715target 'app' do
816 pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
···13211422 use_react_native!(
1523 :path => config[:reactNativePath],
1616- # to enable hermes on iOS, change `false` to `true` and then install pods
2424+ # Hermes is now enabled by default. Disable by setting this flag to false.
2525+ # Upcoming versions of React Native may rely on get_default_flags(), but
2626+ # we make it explicit here to aid in the React Native upgrade process.
1727 :hermes_enabled => flags[:hermes_enabled],
1828 :fabric_enabled => flags[:fabric_enabled],
2929+ # Enables Flipper.
3030+ #
3131+ # Note that if you have use_frameworks! enabled, Flipper will not work and
3232+ # you should disable the next line.
3333+ #:flipper_configuration => flipper_config,
1934 # An absolute path to your application root.
2035 :app_path => "#{Pod::Config.instance.installation_root}/.."
2136 )
···2540 # Pods for testing
2641 end
27422828- # Enables Flipper.
2929- #
3030- # Note that if you have use_frameworks! enabled, Flipper will not work and
3131- # you should disable the next line.
3232- #use_flipper!()
3333-3443 post_install do |installer|
3535- react_native_post_install(installer)
4444+ react_native_post_install(
4545+ installer,
4646+ # Set `mac_catalyst_enabled` to `true` in order to apply patches
4747+ # necessary for Mac Catalyst builds
4848+ :mac_catalyst_enabled => false
4949+ )
3650 __apply_Xcode_12_5_M1_post_install_workaround(installer)
37513852 # iOS fix