···1source 'https://rubygems.org'
23# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-ruby '2.7.4'
56-gem 'cocoapods', '~> 1.11', '>= 1.11.2'
···1source 'https://rubygems.org'
23# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+ruby File.read(File.join(__dir__, '.ruby-version')).strip
56+gem 'cocoapods', '~> 1.11', '>= 1.11.3'
···1apply plugin: "com.android.application"
023import com.android.build.OutputFile
4import org.apache.tools.ant.taskdefs.condition.Os
56/**
7- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
8- * and bundleReleaseJsAndAssets).
9- * These basically call `react-native bundle` with the correct arguments during the Android build
10- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
11- * bundle directly from the development server. Below you can see all the possible configurations
12- * and their defaults. If you decide to add a configuration block, make sure to add it before the
13- * `apply from: "../../node_modules/react-native/react.gradle"` line.
14- *
15- * project.ext.react = [
16- * // the name of the generated asset file containing your JS bundle
17- * bundleAssetName: "index.android.bundle",
18- *
19- * // the entry file for bundle generation. If none specified and
20- * // "index.android.js" exists, it will be used. Otherwise "index.js" is
21- * // default. Can be overridden with ENTRY_FILE environment variable.
22- * entryFile: "index.android.js",
23- *
24- * // https://reactnative.dev/docs/performance#enable-the-ram-format
25- * bundleCommand: "ram-bundle",
26- *
27- * // whether to bundle JS and assets in debug mode
28- * bundleInDebug: false,
29- *
30- * // whether to bundle JS and assets in release mode
31- * bundleInRelease: true,
32- *
33- * // whether to bundle JS and assets in another build variant (if configured).
34- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
35- * // The configuration property can be in the following formats
36- * // 'bundleIn${productFlavor}${buildType}'
37- * // 'bundleIn${buildType}'
38- * // bundleInFreeDebug: true,
39- * // bundleInPaidRelease: true,
40- * // bundleInBeta: true,
41- *
42- * // whether to disable dev mode in custom build variants (by default only disabled in release)
43- * // for example: to disable dev mode in the staging build type (if configured)
44- * devDisabledInStaging: true,
45- * // The configuration property can be in the following formats
46- * // 'devDisabledIn${productFlavor}${buildType}'
47- * // 'devDisabledIn${buildType}'
48- *
49- * // the root of your project, i.e. where "package.json" lives
50- * root: "../../",
51- *
52- * // where to put the JS bundle asset in debug mode
53- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
54- *
55- * // where to put the JS bundle asset in release mode
56- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
57- *
58- * // where to put drawable resources / React Native assets, e.g. the ones you use via
59- * // require('./image.png')), in debug mode
60- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
61- *
62- * // where to put drawable resources / React Native assets, e.g. the ones you use via
63- * // require('./image.png')), in release mode
64- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
65- *
66- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
67- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
68- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
69- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
70- * // for example, you might want to remove it from here.
71- * inputExcludes: ["android/**", "ios/**"],
72- *
73- * // override which node gets called and with what additional arguments
74- * nodeExecutableAndArgs: ["node"],
75- *
76- * // supply additional arguments to the packager
77- * extraPackagerArgs: []
78- * ]
79 */
8081-project.ext.react = [
82- enableHermes: false, // clean and rebuild if changing
83-]
84-85-apply from: "../../node_modules/react-native/react.gradle"
0000000000000000000000000000000000008687/**
88- * Set this to true to create two separate APKs instead of one:
89- * - An APK that only works on ARM devices
90- * - An APK that only works on x86 devices
91- * The advantage is the size of the APK is reduced by about 4MB.
92- * Upload all the APKs to the Play Store and people will download
93- * the correct one based on the CPU architecture of their device.
94 */
95def enableSeparateBuildPerCPUArchitecture = false
9697/**
98- * Run Proguard to shrink the Java bytecode in release builds.
99 */
100def enableProguardInReleaseBuilds = false
101102/**
103- * The preferred build flavor of JavaScriptCore.
104 *
105 * For example, to use the international variant, you can use:
106 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
107 *
108 * The international variant includes ICU i18n library and necessary data
109 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
110- * give correct results when using with locales other than en-US. Note that
111 * this variant is about 6MiB larger per architecture than default.
112 */
113def jscFlavor = 'org.webkit:android-jsc:+'
114115/**
116- * Whether to enable the Hermes VM.
117- *
118- * This should be set on project.ext.react and that value will be read here. If it is not set
119- * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120- * and the benefits of using Hermes will therefore be sharply reduced.
121- */
122-def enableHermes = project.ext.react.get("enableHermes", false);
123-124-/**
125- * Architectures to build native code for.
126 */
127def reactNativeArchitectures() {
128 def value = project.getProperties().get("reactNativeArchitectures")
···134135 compileSdkVersion rootProject.ext.compileSdkVersion
1360137 defaultConfig {
138 applicationId "xyz.blueskyweb.app"
139 minSdkVersion rootProject.ext.minSdkVersion
140 targetSdkVersion rootProject.ext.targetSdkVersion
141 versionCode 1
142 versionName "1.0"
143- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144-145- if (isNewArchitectureEnabled()) {
146- // We configure the NDK build only if you decide to opt-in for the New Architecture.
147- externalNativeBuild {
148- ndkBuild {
149- arguments "APP_PLATFORM=android-21",
150- "APP_STL=c++_shared",
151- "NDK_TOOLCHAIN_VERSION=clang",
152- "GENERATED_SRC_DIR=$buildDir/generated/source",
153- "PROJECT_BUILD_DIR=$buildDir",
154- "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
155- "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
156- cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157- cppFlags "-std=c++17"
158- // Make sure this target name is the same you specify inside the
159- // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160- targets "app_appmodules"
161-162- // Fix for windows limit on number of character in file paths and in command lines
163- if (Os.isFamily(Os.FAMILY_WINDOWS)) {
164- arguments "NDK_APP_SHORT_COMMANDS=true"
165- }
166- }
167- }
168- if (!enableSeparateBuildPerCPUArchitecture) {
169- ndk {
170- abiFilters (*reactNativeArchitectures())
171- }
172- }
173- }
174- }
175-176- if (isNewArchitectureEnabled()) {
177- // We configure the NDK build only if you decide to opt-in for the New Architecture.
178- externalNativeBuild {
179- ndkBuild {
180- path "$projectDir/src/main/jni/Android.mk"
181- }
182- }
183- def reactAndroidProjectDir = project(':ReactAndroid').projectDir
184- def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
185- dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
186- from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
187- into("$buildDir/react-ndk/exported")
188- }
189- def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
190- dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
191- from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
192- into("$buildDir/react-ndk/exported")
193- }
194- afterEvaluate {
195- // If you wish to add a custom TurboModule or component locally,
196- // you should uncomment this line.
197- // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
198- preDebugBuild.dependsOn(packageReactNdkDebugLibs)
199- preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
200-201- // Due to a bug inside AGP, we have to explicitly set a dependency
202- // between configureNdkBuild* tasks and the preBuild tasks.
203- // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
204- configureNdkBuildRelease.dependsOn(preReleaseBuild)
205- configureNdkBuildDebug.dependsOn(preDebugBuild)
206- reactNativeArchitectures().each { architecture ->
207- tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
208- dependsOn("preDebugBuild")
209- }
210- tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
211- dependsOn("preReleaseBuild")
212- }
213- }
214- }
215 }
216217 splits {
···261}
262263dependencies {
264- implementation fileTree(dir: "libs", include: ["*.jar"])
0265266- //noinspection GradleDynamicVersion
267- implementation "com.facebook.react:react-native:+" // From node_modules
268-269- implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
270271 implementation project(':rn-fetch-blob')
272273- debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
274- exclude group:'com.facebook.fbjni'
275- }
276-277 debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
278- exclude group:'com.facebook.flipper'
279 exclude group:'com.squareup.okhttp3', module:'okhttp'
280 }
281282- debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
283- exclude group:'com.facebook.flipper'
284- }
285-286- if (enableHermes) {
287- def hermesPath = "../../node_modules/hermes-engine/android/";
288- debugImplementation files(hermesPath + "hermes-debug.aar")
289- releaseImplementation files(hermesPath + "hermes-release.aar")
290 } else {
291 implementation jscFlavor
292 }
293}
294295-if (isNewArchitectureEnabled()) {
296- // If new architecture is enabled, we let you build RN from source
297- // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
298- // This will be applied to all the imported transtitive dependency.
299- configurations.all {
300- resolutionStrategy.dependencySubstitution {
301- substitute(module("com.facebook.react:react-native"))
302- .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
303- }
304- }
305-}
306-307-// Run this once to be able to run the application with BUCK
308-// puts all compile dependencies into folder libs for BUCK to use
309-task copyDownloadableDepsToLibs(type: Copy) {
310- from configurations.implementation
311- into 'libs'
312-}
313-314apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
315-316-def isNewArchitectureEnabled() {
317- // To opt-in for the New Architecture, you can either:
318- // - Set `newArchEnabled` to true inside the `gradle.properties` file
319- // - Invoke gradle with `-newArchEnabled=true`
320- // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
321- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
322-}
···1apply plugin: "com.android.application"
2+apply plugin: "com.facebook.react"
34import com.android.build.OutputFile
5import org.apache.tools.ant.taskdefs.condition.Os
67/**
8+ * This is the configuration block to customize your React Native Android app.
9+ * By default you don't need to apply any configuration, just uncomment the lines you need.
000000000000000000000000000000000000000000000000000000000000000000000010 */
1112+react {
13+ /* Folders */
14+ // The root of your project, i.e. where "package.json" lives. Default is '..'
15+ // root = file("../")
16+ // The folder where the react-native NPM package is. Default is ../node_modules/react-native
17+ // reactNativeDir = file("../node-modules/react-native")
18+ // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
19+ // codegenDir = file("../node-modules/react-native-codegen")
20+ // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
21+ // cliFile = file("../node_modules/react-native/cli.js")
22+ /* Variants */
23+ // The list of variants to that are debuggable. For those we're going to
24+ // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
25+ // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
26+ // debuggableVariants = ["liteDebug", "prodDebug"]
27+ /* Bundling */
28+ // A list containing the node command and its flags. Default is just 'node'.
29+ // nodeExecutableAndArgs = ["node"]
30+ //
31+ // The command to run when bundling. By default is 'bundle'
32+ // bundleCommand = "ram-bundle"
33+ //
34+ // The path to the CLI configuration file. Default is empty.
35+ // bundleConfig = file(../rn-cli.config.js)
36+ //
37+ // The name of the generated asset file containing your JS bundle
38+ // bundleAssetName = "MyApplication.android.bundle"
39+ //
40+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
41+ // entryFile = file("../js/MyApplication.android.js")
42+ //
43+ // A list of extra flags to pass to the 'bundle' commands.
44+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
45+ // extraPackagerArgs = []
46+ /* Hermes Commands */
47+ // The hermes compiler command to run. By default it is 'hermesc'
48+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49+ //
50+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51+ // hermesFlags = ["-O", "-output-source-map"]
52+}
5354/**
55+ * Set this to true to create four separate APKs instead of one,
56+ * one for each native architecture. This is useful if you don't
57+ * use App Bundles (https://developer.android.com/guide/app-bundle/)
58+ * and want to have separate APKs to upload to the Play Store.
0059 */
60def enableSeparateBuildPerCPUArchitecture = false
6162/**
63+ * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
64 */
65def enableProguardInReleaseBuilds = false
6667/**
68+ * The preferred build flavor of JavaScriptCore (JSC)
69 *
70 * For example, to use the international variant, you can use:
71 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
72 *
73 * The international variant includes ICU i18n library and necessary data
74 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
75+ * give correct results when using with locales other than en-US. Note that
76 * this variant is about 6MiB larger per architecture than default.
77 */
78def jscFlavor = 'org.webkit:android-jsc:+'
7980/**
81+ * Private function to get the list of Native Architectures you want to build.
82+ * This reads the value from reactNativeArchitectures in your gradle.properties
83+ * file and works together with the --active-arch-only flag of react-native run-android.
000000084 */
85def reactNativeArchitectures() {
86 def value = project.getProperties().get("reactNativeArchitectures")
···9293 compileSdkVersion rootProject.ext.compileSdkVersion
9495+ namespace "xyz.blueskyweb.app"
96 defaultConfig {
97 applicationId "xyz.blueskyweb.app"
98 minSdkVersion rootProject.ext.minSdkVersion
99 targetSdkVersion rootProject.ext.targetSdkVersion
100 versionCode 1
101 versionName "1.0"
000000000000000000000000000000000000000000000000000000000000000000000000102 }
103104 splits {
···148}
149150dependencies {
151+ // The version of react-native is set by the React Native Gradle Plugin
152+ implementation("com.facebook.react:react-android")
153154+ implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
000155156 implementation project(':rn-fetch-blob')
157158+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
000159 debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
0160 exclude group:'com.squareup.okhttp3', module:'okhttp'
161 }
162163+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
164+ if (hermesEnabled.toBoolean()) {
165+ implementation("com.facebook.react:hermes-android")
00000166 } else {
167 implementation jscFlavor
168 }
169}
1700000000000000000000171apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
00000000
-19
android/app/build_defs.bzl
···1-"""Helper definitions to glob .aar and .jar targets"""
2-3-def create_aar_targets(aarfiles):
4- for aarfile in aarfiles:
5- name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6- lib_deps.append(":" + name)
7- android_prebuilt_aar(
8- name = name,
9- aar = aarfile,
10- )
11-12-def create_jar_targets(jarfiles):
13- for jarfile in jarfiles:
14- name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15- lib_deps.append(":" + name)
16- prebuilt_jar(
17- name = name,
18- binary_jar = jarfile,
19- )
···25import com.facebook.react.modules.network.NetworkingModule;
26import okhttp3.OkHttpClient;
2728+/**
29+ * Class responsible of loading Flipper inside your React Native application. This is the debug
30+ * flavor of it. Here you can add your own plugins and customize the Flipper setup.
31+ */
32public class ReactNativeFlipper {
33 public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
34 if (FlipperUtils.shouldEnableFlipper(context)) {
35 final FlipperClient client = AndroidFlipperClient.getInstance(context);
3637 client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
038 client.addPlugin(new DatabasesFlipperPlugin(context));
39 client.addPlugin(new SharedPreferencesFlipperPlugin(context));
40 client.addPlugin(CrashReporterPlugin.getInstance());
···23import com.facebook.react.ReactActivity;
4import com.facebook.react.ReactActivityDelegate;
5-import com.facebook.react.ReactRootView;
06import android.os.Bundle;
78public class MainActivity extends ReactActivity {
···17 }
1819 /**
20- * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
21- * you can specify the rendered you wish to use (Fabric or the older renderer).
022 */
23 @Override
24 protected ReactActivityDelegate createReactActivityDelegate() {
25- return new MainActivityDelegate(this, getMainComponentName());
26- }
27-28- public static class MainActivityDelegate extends ReactActivityDelegate {
29- public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
30- super(activity, mainComponentName);
31- }
32-33- @Override
34- protected ReactRootView createRootView() {
35- ReactRootView reactRootView = new ReactRootView(getContext());
36 // If you opted-in for the New Architecture, we enable the Fabric Renderer.
37- reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
38- return reactRootView;
39- }
40-41- @Override
42- protected void onCreate(Bundle savedInstanceState) {
43- super.onCreate(null);
44- }
45 }
46}
···23import com.facebook.react.ReactActivity;
4import com.facebook.react.ReactActivityDelegate;
5+import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
6+import com.facebook.react.defaults.DefaultReactActivityDelegate;
7import android.os.Bundle;
89public class MainActivity extends ReactActivity {
···18 }
1920 /**
21+ * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
22+ * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
23+ * (aka React 18) with two boolean flags.
24 */
25 @Override
26 protected ReactActivityDelegate createReactActivityDelegate() {
27+ return new DefaultReactActivityDelegate(
28+ this,
29+ getMainComponentName(),
0000000030 // If you opted-in for the New Architecture, we enable the Fabric Renderer.
31+ DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
32+ // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
33+ DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
34+ );
000035 }
36}
···1-package xyz.blueskyweb.app.newarchitecture;
2-3-import android.app.Application;
4-import androidx.annotation.NonNull;
5-import com.facebook.react.PackageList;
6-import com.facebook.react.ReactInstanceManager;
7-import com.facebook.react.ReactNativeHost;
8-import com.facebook.react.ReactPackage;
9-import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
10-import com.facebook.react.bridge.JSIModulePackage;
11-import com.facebook.react.bridge.JSIModuleProvider;
12-import com.facebook.react.bridge.JSIModuleSpec;
13-import com.facebook.react.bridge.JSIModuleType;
14-import com.facebook.react.bridge.JavaScriptContextHolder;
15-import com.facebook.react.bridge.ReactApplicationContext;
16-import com.facebook.react.bridge.UIManager;
17-import com.facebook.react.fabric.ComponentFactory;
18-import com.facebook.react.fabric.CoreComponentsRegistry;
19-import com.facebook.react.fabric.EmptyReactNativeConfig;
20-import com.facebook.react.fabric.FabricJSIModuleProvider;
21-import com.facebook.react.uimanager.ViewManagerRegistry;
22-import xyz.blueskyweb.app.BuildConfig;
23-import xyz.blueskyweb.app.newarchitecture.components.MainComponentsRegistry;
24-import xyz.blueskyweb.app.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
25-import java.util.ArrayList;
26-import java.util.List;
27-28-/**
29- * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
30- * TurboModule delegates and the Fabric Renderer.
31- *
32- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
33- * `newArchEnabled` property). Is ignored otherwise.
34- */
35-public class MainApplicationReactNativeHost extends ReactNativeHost {
36- public MainApplicationReactNativeHost(Application application) {
37- super(application);
38- }
39-40- @Override
41- public boolean getUseDeveloperSupport() {
42- return BuildConfig.DEBUG;
43- }
44-45- @Override
46- protected List<ReactPackage> getPackages() {
47- List<ReactPackage> packages = new PackageList(this).getPackages();
48- // Packages that cannot be autolinked yet can be added manually here, for example:
49- // packages.add(new MyReactNativePackage());
50- // TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
51- // packages.add(new TurboReactPackage() { ... });
52- // If you have custom Fabric Components, their ViewManagers should also be loaded here
53- // inside a ReactPackage.
54- return packages;
55- }
56-57- @Override
58- protected String getJSMainModuleName() {
59- return "index";
60- }
61-62- @NonNull
63- @Override
64- protected ReactPackageTurboModuleManagerDelegate.Builder
65- getReactPackageTurboModuleManagerDelegateBuilder() {
66- // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
67- // for the new architecture and to use TurboModules correctly.
68- return new MainApplicationTurboModuleManagerDelegate.Builder();
69- }
70-71- @Override
72- protected JSIModulePackage getJSIModulePackage() {
73- return new JSIModulePackage() {
74- @Override
75- public List<JSIModuleSpec> getJSIModules(
76- final ReactApplicationContext reactApplicationContext,
77- final JavaScriptContextHolder jsContext) {
78- final List<JSIModuleSpec> specs = new ArrayList<>();
79-80- // Here we provide a new JSIModuleSpec that will be responsible of providing the
81- // custom Fabric Components.
82- specs.add(
83- new JSIModuleSpec() {
84- @Override
85- public JSIModuleType getJSIModuleType() {
86- return JSIModuleType.UIManager;
87- }
88-89- @Override
90- public JSIModuleProvider<UIManager> getJSIModuleProvider() {
91- final ComponentFactory componentFactory = new ComponentFactory();
92- CoreComponentsRegistry.register(componentFactory);
93-94- // Here we register a Components Registry.
95- // The one that is generated with the template contains no components
96- // and just provides you the one from React Native core.
97- MainComponentsRegistry.register(componentFactory);
98-99- final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
100-101- ViewManagerRegistry viewManagerRegistry =
102- new ViewManagerRegistry(
103- reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
104-105- return new FabricJSIModuleProvider(
106- reactApplicationContext,
107- componentFactory,
108- new EmptyReactNativeConfig(),
109- viewManagerRegistry);
110- }
111- });
112- return specs;
113- }
114- };
115- }
116-}
···1-package xyz.blueskyweb.app.newarchitecture.components;
2-3-import com.facebook.jni.HybridData;
4-import com.facebook.proguard.annotations.DoNotStrip;
5-import com.facebook.react.fabric.ComponentFactory;
6-import com.facebook.soloader.SoLoader;
7-8-/**
9- * Class responsible to load the custom Fabric Components. This class has native methods and needs a
10- * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
11- * folder for you).
12- *
13- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
14- * `newArchEnabled` property). Is ignored otherwise.
15- */
16-@DoNotStrip
17-public class MainComponentsRegistry {
18- static {
19- SoLoader.loadLibrary("fabricjni");
20- }
21-22- @DoNotStrip private final HybridData mHybridData;
23-24- @DoNotStrip
25- private native HybridData initHybrid(ComponentFactory componentFactory);
26-27- @DoNotStrip
28- private MainComponentsRegistry(ComponentFactory componentFactory) {
29- mHybridData = initHybrid(componentFactory);
30- }
31-32- @DoNotStrip
33- public static MainComponentsRegistry register(ComponentFactory componentFactory) {
34- return new MainComponentsRegistry(componentFactory);
35- }
36-}
···1-package xyz.blueskyweb.app.newarchitecture.modules;
2-3-import com.facebook.jni.HybridData;
4-import com.facebook.react.ReactPackage;
5-import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
6-import com.facebook.react.bridge.ReactApplicationContext;
7-import com.facebook.soloader.SoLoader;
8-import java.util.List;
9-10-/**
11- * Class responsible to load the TurboModules. This class has native methods and needs a
12- * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
13- * folder for you).
14- *
15- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
16- * `newArchEnabled` property). Is ignored otherwise.
17- */
18-public class MainApplicationTurboModuleManagerDelegate
19- extends ReactPackageTurboModuleManagerDelegate {
20-21- private static volatile boolean sIsSoLibraryLoaded;
22-23- protected MainApplicationTurboModuleManagerDelegate(
24- ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
25- super(reactApplicationContext, packages);
26- }
27-28- protected native HybridData initHybrid();
29-30- native boolean canCreateTurboModule(String moduleName);
31-32- public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
33- protected MainApplicationTurboModuleManagerDelegate build(
34- ReactApplicationContext context, List<ReactPackage> packages) {
35- return new MainApplicationTurboModuleManagerDelegate(context, packages);
36- }
37- }
38-39- @Override
40- protected synchronized void maybeLoadOtherSoLibraries() {
41- if (!sIsSoLibraryLoaded) {
42- // If you change the name of your application .so file in the Android.mk file,
43- // make sure you update the name here as well.
44- SoLoader.loadLibrary("app_appmodules");
45- sIsSoLibraryLoaded = true;
46- }
47- }
48-}
···1-#include "MainApplicationModuleProvider.h"
2-3-#include <rncore.h>
4-5-namespace facebook {
6-namespace react {
7-8-std::shared_ptr<TurboModule> MainApplicationModuleProvider(
9- const std::string moduleName,
10- const JavaTurboModule::InitParams ¶ms) {
11- // Here you can provide your own module provider for TurboModules coming from
12- // either your application or from external libraries. The approach to follow
13- // is similar to the following (for a library called `samplelibrary`:
14- //
15- // auto module = samplelibrary_ModuleProvider(moduleName, params);
16- // if (module != nullptr) {
17- // return module;
18- // }
19- // return rncore_ModuleProvider(moduleName, params);
20- return rncore_ModuleProvider(moduleName, params);
21-}
22-23-} // namespace react
24-} // namespace facebook
···1+/**
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+ * directory of this source tree.
6+ */
7+package xyz.blueskyweb.app;
8+import android.content.Context;
9+import com.facebook.react.ReactInstanceManager;
10+/**
11+ * Class responsible of loading Flipper inside your React Native application. This is the release
12+ * flavor of it so it's empty as we don't want to load Flipper.
13+ */
14+public class ReactNativeFlipper {
15+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
16+ // Do nothing as we don't want to initialize Flipper on Release.
17+ }
18+}
+3-34
android/build.gradle
···9 compileSdkVersion = 33
10 targetSdkVersion = 33
1112- if (System.properties['os.arch'] == "aarch64") {
13- // For M1 Users we need to use the NDK 24 which added support for aarch64
14- ndkVersion = "24.0.8215888"
15- } else {
16- // Otherwise we default to the side-by-side NDK version from AGP.
17- ndkVersion = "21.4.7075529"
18- }
19 }
20 repositories {
21 google()
22 mavenCentral()
23 }
24 dependencies {
25- classpath('com.android.tools.build:gradle:7.2.1')
26 classpath("com.facebook.react:react-native-gradle-plugin")
27- classpath("de.undercouch:gradle-download-task:4.1.2")
28- // NOTE: Do not place your application dependencies here; they belong
29- // in the individual module build.gradle files
30- }
31-}
32-33-allprojects {
34- repositories {
35- maven {
36- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
37- url("$rootDir/../node_modules/react-native/android")
38- }
39- maven {
40- // Android JSC is installed from npm
41- url("$rootDir/../node_modules/jsc-android/dist")
42- }
43- mavenCentral {
44- // We don't want to fetch react-native from Maven Central as there are
45- // older versions over there.
46- content {
47- excludeGroup "com.facebook.react"
48- }
49- }
50- google()
51- maven { url 'https://www.jitpack.io' }
52- maven { url 'https://maven.google.com' }
53 }
54}
···9 compileSdkVersion = 33
10 targetSdkVersion = 33
1112+ // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
13+ ndkVersion = "23.1.7779620"
0000014 }
15 repositories {
16 google()
17 mavenCentral()
18 }
19 dependencies {
20+ classpath("com.android.tools.build:gradle:7.3.1")
21 classpath("com.facebook.react:react-native-gradle-plugin")
0000000000000000000000000022 }
23}
+4
android/gradle.properties
···38# to write custom TurboModules/Fabric components OR use libraries that
39# are providing them.
40newArchEnabled=false
0000
···38# to write custom TurboModules/Fabric components OR use libraries that
39# are providing them.
40newArchEnabled=false
41+42+# Use this property to enable or disable the Hermes JS engine.
43+# If set to false, you will be using JSC instead.
44+hermesEnabled=true
···4includeBuild('../node_modules/react-native-gradle-plugin')
5include ':rn-fetch-blob'
6project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
0000
+10
ios/.xcode.env
···0000000000
···1+# This `.xcode.env` file is versioned and is used to source the environment
2+# used when running script phases inside Xcode.
3+# To customize your local environment, you can create an `.xcode.env.local`
4+# file that is not versioned.
5+# NODE_BINARY variable contains the PATH to the node executable.
6+#
7+# Customize the NODE_BINARY variable here.
8+# For example, to use nvm with brew, add the following line
9+# . "$(brew --prefix nvm)/nvm.sh" --no-use
10+export NODE_BINARY=$(command -v node)
+24-10
ios/Podfile
···1require_relative '../node_modules/react-native/scripts/react_native_pods'
2require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
34-platform :ios, '11.0'
5-install! 'cocoapods', :deterministic_uuids => false
0000000067target 'app' do
8 pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
···1314 use_react_native!(
15 :path => config[:reactNativePath],
16- # to enable hermes on iOS, change `false` to `true` and then install pods
0017 :hermes_enabled => flags[:hermes_enabled],
18 :fabric_enabled => flags[:fabric_enabled],
0000019 # An absolute path to your application root.
20 :app_path => "#{Pod::Config.instance.installation_root}/.."
21 )
···25 # Pods for testing
26 end
2728- # Enables Flipper.
29- #
30- # Note that if you have use_frameworks! enabled, Flipper will not work and
31- # you should disable the next line.
32- #use_flipper!()
33-34 post_install do |installer|
35- react_native_post_install(installer)
0000036 __apply_Xcode_12_5_M1_post_install_workaround(installer)
3738 # iOS fix
···1require_relative '../node_modules/react-native/scripts/react_native_pods'
2require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
34+platform :ios, min_ios_version_supported
5+prepare_react_native_project!
6+7+flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
8+9+linkage = ENV['USE_FRAMEWORKS']
10+if linkage != nil
11+ Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
12+ use_frameworks! :linkage => linkage.to_sym
13+end
1415target 'app' do
16 pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
···2122 use_react_native!(
23 :path => config[:reactNativePath],
24+ # Hermes is now enabled by default. Disable by setting this flag to false.
25+ # Upcoming versions of React Native may rely on get_default_flags(), but
26+ # we make it explicit here to aid in the React Native upgrade process.
27 :hermes_enabled => flags[:hermes_enabled],
28 :fabric_enabled => flags[:fabric_enabled],
29+ # Enables Flipper.
30+ #
31+ # Note that if you have use_frameworks! enabled, Flipper will not work and
32+ # you should disable the next line.
33+ #:flipper_configuration => flipper_config,
34 # An absolute path to your application root.
35 :app_path => "#{Pod::Config.instance.installation_root}/.."
36 )
···40 # Pods for testing
41 end
4200000043 post_install do |installer|
44+ react_native_post_install(
45+ installer,
46+ # Set `mac_catalyst_enabled` to `true` in order to apply patches
47+ # necessary for Mac Catalyst builds
48+ :mac_catalyst_enabled => false
49+ )
50 __apply_Xcode_12_5_M1_post_install_workaround(installer)
5152 # iOS fix