From fe6f3402bafab868eee8a77b122e83ee46b473c9 Mon Sep 17 00:00:00 2001 From: Sebastian Alex Date: Thu, 26 Sep 2024 17:18:02 +0200 Subject: [PATCH 1/7] react-native example: update to newest react-native boilerplate code --- examples/sdk/reactNative/.gitignore | 12 +- examples/sdk/reactNative/Gemfile | 4 +- examples/sdk/reactNative/Gemfile.lock | 60 +- .../sdk/reactNative/android/app/build.gradle | 38 +- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../com/reactnative/ReactNativeFlipper.java | 75 - .../android/app/src/main/AndroidManifest.xml | 3 +- .../com/reactnative/BacktraceDemoPackage.java | 29 - .../java/com/reactnative/ErrorGenerator.java | 33 - .../java/com/reactnative/MainActivity.java | 32 - .../java/com/reactnative/MainApplication.java | 62 - .../main/java/com/rnbtexample/MainActivity.kt | 22 + .../java/com/rnbtexample/MainApplication.kt | 43 + .../res/drawable/rn_edit_text_material.xml | 3 +- .../app/src/main/res/values/strings.xml | 2 +- .../main/res/xml/network_security_config.xml | 0 .../com/reactnative/ReactNativeFlipper.java | 20 - examples/sdk/reactNative/android/build.gradle | 18 +- .../sdk/reactNative/android/gradle.properties | 5 - .../android/gradle/wrapper/gradle-wrapper.jar | Bin 61574 -> 43453 bytes .../gradle/wrapper/gradle-wrapper.properties | 3 +- examples/sdk/reactNative/android/gradlew | 31 +- examples/sdk/reactNative/android/gradlew.bat | 20 +- .../sdk/reactNative/android/settings.gradle | 6 +- examples/sdk/reactNative/app.json | 4 +- examples/sdk/reactNative/babel.config.js | 2 +- examples/sdk/reactNative/ios/Podfile | 30 +- examples/sdk/reactNative/ios/Podfile.lock | 1960 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../project.pbxproj | 229 +- .../xcschemes/rnbtexample.xcscheme} | 24 +- .../contents.xcworkspacedata | 2 +- .../AppDelegate.h | 0 .../AppDelegate.mm | 7 +- .../AppIcon.appiconset/Contents.json | 0 .../Images.xcassets/Contents.json | 0 .../{reactNative => rnbtexample}/Info.plist | 17 +- .../LaunchScreen.storyboard | 2 +- .../ios/rnbtexample/PrivacyInfo.xcprivacy | 37 + .../ios/{reactNative => rnbtexample}/main.m | 0 .../Info.plist | 0 .../rnbtexampleTests.m} | 4 +- examples/sdk/reactNative/metro.config.js | 18 +- examples/sdk/reactNative/package-lock.json | 22787 +++++----------- examples/sdk/reactNative/package.json | 27 +- examples/sdk/reactNative/tsconfig.json | 2 +- package-lock.json | 1 + package.json | 1 + 48 files changed, 8313 insertions(+), 17376 deletions(-) delete mode 100644 examples/sdk/reactNative/android/app/src/debug/java/com/reactnative/ReactNativeFlipper.java delete mode 100644 examples/sdk/reactNative/android/app/src/main/java/com/reactnative/BacktraceDemoPackage.java delete mode 100644 examples/sdk/reactNative/android/app/src/main/java/com/reactnative/ErrorGenerator.java delete mode 100644 examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainActivity.java delete mode 100644 examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainApplication.java create mode 100644 examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainActivity.kt create mode 100644 examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainApplication.kt delete mode 100644 examples/sdk/reactNative/android/app/src/main/res/xml/network_security_config.xml delete mode 100644 examples/sdk/reactNative/android/app/src/release/java/com/reactnative/ReactNativeFlipper.java delete mode 100644 examples/sdk/reactNative/ios/reactNative.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename examples/sdk/reactNative/ios/{reactNative.xcodeproj => rnbtexample.xcodeproj}/project.pbxproj (71%) rename examples/sdk/reactNative/ios/{reactNative.xcodeproj/xcshareddata/xcschemes/reactNative.xcscheme => rnbtexample.xcodeproj/xcshareddata/xcschemes/rnbtexample.xcscheme} (80%) rename examples/sdk/reactNative/ios/{reactNative.xcworkspace => rnbtexample.xcworkspace}/contents.xcworkspacedata (79%) rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/AppDelegate.h (100%) rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/AppDelegate.mm (88%) rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/Images.xcassets/AppIcon.appiconset/Contents.json (100%) rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/Images.xcassets/Contents.json (100%) rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/Info.plist (85%) rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/LaunchScreen.storyboard (98%) create mode 100644 examples/sdk/reactNative/ios/rnbtexample/PrivacyInfo.xcprivacy rename examples/sdk/reactNative/ios/{reactNative => rnbtexample}/main.m (100%) rename examples/sdk/reactNative/ios/{reactNativeTests => rnbtexampleTests}/Info.plist (100%) rename examples/sdk/reactNative/ios/{reactNativeTests/reactNativeTests.m => rnbtexampleTests/rnbtexampleTests.m} (96%) diff --git a/examples/sdk/reactNative/.gitignore b/examples/sdk/reactNative/.gitignore index 0cab2ac6..d5ae4566 100644 --- a/examples/sdk/reactNative/.gitignore +++ b/examples/sdk/reactNative/.gitignore @@ -20,7 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate -ios/.xcode.env.local +**/.xcode.env.local # Android/IntelliJ # @@ -56,7 +56,7 @@ yarn-error.log *.jsbundle # Ruby / CocoaPods -/ios/Pods/ +**/Pods/ /vendor/bundle/ # Temporary files created by Metro to check the health of the file watcher @@ -64,3 +64,11 @@ yarn-error.log # testing /coverage + +# Yarn +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/examples/sdk/reactNative/Gemfile b/examples/sdk/reactNative/Gemfile index 1fa2c2e1..2a7ce357 100644 --- a/examples/sdk/reactNative/Gemfile +++ b/examples/sdk/reactNative/Gemfile @@ -3,4 +3,6 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version ruby ">= 2.6.10" -gem 'cocoapods', '~> 1.12' +# Exclude problematic versions of cocoapods and activesupport that causes build failures. +gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1' +gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0' diff --git a/examples/sdk/reactNative/Gemfile.lock b/examples/sdk/reactNative/Gemfile.lock index a3cc98d0..16f21cba 100644 --- a/examples/sdk/reactNative/Gemfile.lock +++ b/examples/sdk/reactNative/Gemfile.lock @@ -1,27 +1,35 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.6) + CFPropertyList (3.0.7) + base64 + nkf rexml - activesupport (6.1.7.4) + activesupport (7.1.4) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.5) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) + base64 (0.2.0) + bigdecimal (3.1.8) claide (1.1.0) - cocoapods (1.12.1) + cocoapods (1.15.2) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.12.1) + cocoapods-core (= 1.15.2) cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.6.0, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-trunk (>= 1.6.0, < 2.0) @@ -33,8 +41,8 @@ GEM molinillo (~> 0.8.0) nap (~> 1.0) ruby-macho (>= 2.3.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.12.1) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.15.2) activesupport (>= 5.0, < 8) addressable (~> 2.8) algoliasearch (~> 1.0) @@ -45,7 +53,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.6.3) + cocoapods-downloader (2.1) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -54,47 +62,51 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + drb (2.2.1) escape (0.0.4) ethon (0.16.0) ffi (>= 1.15.0) - ffi (1.15.5) + ffi (1.17.0) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) - json (2.6.3) - minitest (5.19.0) + json (2.7.2) + minitest (5.25.1) molinillo (0.8.0) + mutex_m (0.2.0) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) + nkf (0.2.0) public_suffix (4.0.7) - rexml (3.2.6) + rexml (3.3.7) ruby-macho (2.5.1) - typhoeus (1.4.0) + typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.22.0) + xcodeproj (1.25.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) - rexml (~> 3.2.4) - zeitwerk (2.6.11) + rexml (>= 3.3.2, < 4.0) PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.12) + activesupport (>= 6.1.7.5, != 7.1.0) + cocoapods (>= 1.13, != 1.15.1, != 1.15.0) RUBY VERSION - ruby 2.6.10p210 + ruby 2.7.8p225 BUNDLED WITH - 1.17.2 + 2.1.4 diff --git a/examples/sdk/reactNative/android/app/build.gradle b/examples/sdk/reactNative/android/app/build.gradle index 6cab7ea5..f7a6a72d 100644 --- a/examples/sdk/reactNative/android/app/build.gradle +++ b/examples/sdk/reactNative/android/app/build.gradle @@ -1,4 +1,5 @@ apply plugin: "com.android.application" +apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" /** @@ -7,20 +8,20 @@ apply plugin: "com.facebook.react" */ react { /* Folders */ - // The root of your project, i.e. where "package.json" lives. Default is '..' - // root = file("../") - // The folder where the react-native NPM package is. Default is ../node_modules/react-native - // reactNativeDir = file("../node_modules/react-native") - // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen - // codegenDir = file("../node_modules/@react-native/codegen") - // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js - // cliFile = file("../node_modules/react-native/cli.js") + // The root of your project, i.e. where "package.json" lives. Default is '../..' + // root = file("../../") + // The folder where the react-native NPM package is. Default is ../../node_modules/react-native + // reactNativeDir = file("../../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen + // codegenDir = file("../../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js + // cliFile = file("../../node_modules/react-native/cli.js") /* Variants */ // The list of variants to that are debuggable. For those we're going to // skip the bundling of the JS bundle and the assets. By default is just 'debug'. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. - debuggableVariants = ["release"] + // debuggableVariants = ["liteDebug", "prodDebug"] /* Bundling */ // A list containing the node command and its flags. Default is just 'node'. @@ -48,6 +49,9 @@ react { // // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" // hermesFlags = ["-O", "-output-source-map"] + + /* Autolinking */ + autolinkLibrariesWithApp() } /** @@ -70,12 +74,12 @@ def jscFlavor = 'org.webkit:android-jsc:+' android { ndkVersion rootProject.ext.ndkVersion + buildToolsVersion rootProject.ext.buildToolsVersion + compileSdk rootProject.ext.compileSdkVersion - compileSdkVersion rootProject.ext.compileSdkVersion - - namespace "com.reactnative" + namespace "com.rnbtexample" defaultConfig { - applicationId "com.reactnative" + applicationId "com.rnbtexample" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 @@ -107,17 +111,9 @@ dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") - debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { - exclude group:'com.squareup.okhttp3', module:'okhttp' - } - - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } } - -apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/examples/sdk/reactNative/android/app/src/debug/AndroidManifest.xml b/examples/sdk/reactNative/android/app/src/debug/AndroidManifest.xml index 4b185bc1..eb98c01a 100644 --- a/examples/sdk/reactNative/android/app/src/debug/AndroidManifest.xml +++ b/examples/sdk/reactNative/android/app/src/debug/AndroidManifest.xml @@ -2,12 +2,8 @@ - - - - + tools:ignore="GoogleAppIndexingWarning"/> diff --git a/examples/sdk/reactNative/android/app/src/debug/java/com/reactnative/ReactNativeFlipper.java b/examples/sdk/reactNative/android/app/src/debug/java/com/reactnative/ReactNativeFlipper.java deleted file mode 100644 index 9e949578..00000000 --- a/examples/sdk/reactNative/android/app/src/debug/java/com/reactnative/ReactNativeFlipper.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - *

This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. - */ -package com.reactnative; - -import android.content.Context; -import com.facebook.flipper.android.AndroidFlipperClient; -import com.facebook.flipper.android.utils.FlipperUtils; -import com.facebook.flipper.core.FlipperClient; -import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; -import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; -import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; -import com.facebook.flipper.plugins.inspector.DescriptorMapping; -import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; -import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; -import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; -import com.facebook.react.ReactInstanceEventListener; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.modules.network.NetworkingModule; -import okhttp3.OkHttpClient; - -/** - * Class responsible of loading Flipper inside your React Native application. This is the debug - * flavor of it. Here you can add your own plugins and customize the Flipper setup. - */ -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - if (FlipperUtils.shouldEnableFlipper(context)) { - final FlipperClient client = AndroidFlipperClient.getInstance(context); - - client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new DatabasesFlipperPlugin(context)); - client.addPlugin(new SharedPreferencesFlipperPlugin(context)); - client.addPlugin(CrashReporterPlugin.getInstance()); - - NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); - NetworkingModule.setCustomClientBuilder( - new NetworkingModule.CustomClientBuilder() { - @Override - public void apply(OkHttpClient.Builder builder) { - builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); - } - }); - client.addPlugin(networkFlipperPlugin); - client.start(); - - // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized - // Hence we run if after all native modules have been initialized - ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); - if (reactContext == null) { - reactInstanceManager.addReactInstanceEventListener( - new ReactInstanceEventListener() { - @Override - public void onReactContextInitialized(ReactContext reactContext) { - reactInstanceManager.removeReactInstanceEventListener(this); - reactContext.runOnNativeModulesQueueThread( - new Runnable() { - @Override - public void run() { - client.addPlugin(new FrescoFlipperPlugin()); - } - }); - } - }); - } else { - client.addPlugin(new FrescoFlipperPlugin()); - } - } - } -} diff --git a/examples/sdk/reactNative/android/app/src/main/AndroidManifest.xml b/examples/sdk/reactNative/android/app/src/main/AndroidManifest.xml index 4122f36a..e1892528 100644 --- a/examples/sdk/reactNative/android/app/src/main/AndroidManifest.xml +++ b/examples/sdk/reactNative/android/app/src/main/AndroidManifest.xml @@ -8,7 +8,8 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:supportsRtl="true"> createViewManagers(ReactApplicationContext reactContext) { - return Collections.emptyList(); - } - - @Override - public List createNativeModules( - ReactApplicationContext reactContext) { - List modules = new ArrayList<>(); - - modules.add(new ErrorGenerator(reactContext)); - - return modules; - } - -} \ No newline at end of file diff --git a/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/ErrorGenerator.java b/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/ErrorGenerator.java deleted file mode 100644 index 47e8717e..00000000 --- a/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/ErrorGenerator.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.reactnative; - -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactMethod; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -public class ErrorGenerator extends ReactContextBaseJavaModule { - ErrorGenerator(ReactApplicationContext context) { - super(context); - } - - @Override - public String getName() { - return "ErrorGenerator"; - } - - @ReactMethod - public void throwError() throws IOException { - readUserConfiguration(); - } - - private void readUserConfiguration() throws IOException { - // I know for sure this file is there (spoiler alert, it's not) - File mConfiguration = new File("configuration.json"); - FileReader mConfigurationDataReader = new FileReader(mConfiguration); - char[] configurationDataBuffer = new char[255]; - mConfigurationDataReader.read(configurationDataBuffer); - } -} \ No newline at end of file diff --git a/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainActivity.java b/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainActivity.java deleted file mode 100644 index 566c060c..00000000 --- a/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.reactnative; - -import com.facebook.react.ReactActivity; -import com.facebook.react.ReactActivityDelegate; -import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; -import com.facebook.react.defaults.DefaultReactActivityDelegate; - -public class MainActivity extends ReactActivity { - - /** - * Returns the name of the main component registered from JavaScript. This is used to schedule - * rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "reactNative"; - } - - /** - * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link - * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React - * (aka React 18) with two boolean flags. - */ - @Override - protected ReactActivityDelegate createReactActivityDelegate() { - return new DefaultReactActivityDelegate( - this, - getMainComponentName(), - // If you opted-in for the New Architecture, we enable the Fabric Renderer. - DefaultNewArchitectureEntryPoint.getFabricEnabled()); - } -} diff --git a/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainApplication.java b/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainApplication.java deleted file mode 100644 index d9b493f9..00000000 --- a/examples/sdk/reactNative/android/app/src/main/java/com/reactnative/MainApplication.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.reactnative; - -import android.app.Application; -import com.facebook.react.PackageList; -import com.facebook.react.ReactApplication; -import com.facebook.react.ReactNativeHost; -import com.facebook.react.ReactPackage; -import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; -import com.facebook.react.defaults.DefaultReactNativeHost; -import com.facebook.soloader.SoLoader; -import java.util.List; - -public class MainApplication extends Application implements ReactApplication { - - private final ReactNativeHost mReactNativeHost = - new DefaultReactNativeHost(this) { - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } - - @Override - protected List getPackages() { - @SuppressWarnings("UnnecessaryLocalVariable") - List packages = new PackageList(this).getPackages(); - // Packages that cannot be autolinked yet can be added manually here, for example: - packages.add(new BacktraceDemoPackage()); - return packages; - } - - @Override - protected String getJSMainModuleName() { - return "index"; - } - - @Override - protected boolean isNewArchEnabled() { - return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; - } - - @Override - protected Boolean isHermesEnabled() { - return BuildConfig.IS_HERMES_ENABLED; - } - }; - - @Override - public ReactNativeHost getReactNativeHost() { - return mReactNativeHost; - } - - @Override - public void onCreate() { - super.onCreate(); - SoLoader.init(this, /* native exopackage */ false); - if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - // If you opted-in for the New Architecture, we load the native entry point for this app. - DefaultNewArchitectureEntryPoint.load(); - } - ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - } -} diff --git a/examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainActivity.kt b/examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainActivity.kt new file mode 100644 index 00000000..7c177f40 --- /dev/null +++ b/examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainActivity.kt @@ -0,0 +1,22 @@ +package com.rnbtexample + +import com.facebook.react.ReactActivity +import com.facebook.react.ReactActivityDelegate +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled +import com.facebook.react.defaults.DefaultReactActivityDelegate + +class MainActivity : ReactActivity() { + + /** + * Returns the name of the main component registered from JavaScript. This is used to schedule + * rendering of the component. + */ + override fun getMainComponentName(): String = "rnbtexample" + + /** + * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate] + * which allows you to enable New Architecture with a single boolean flags [fabricEnabled] + */ + override fun createReactActivityDelegate(): ReactActivityDelegate = + DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled) +} diff --git a/examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainApplication.kt b/examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainApplication.kt new file mode 100644 index 00000000..ca46880e --- /dev/null +++ b/examples/sdk/reactNative/android/app/src/main/java/com/rnbtexample/MainApplication.kt @@ -0,0 +1,43 @@ +package com.rnbtexample + +import android.app.Application +import com.facebook.react.PackageList +import com.facebook.react.ReactApplication +import com.facebook.react.ReactHost +import com.facebook.react.ReactNativeHost +import com.facebook.react.ReactPackage +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load +import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost +import com.facebook.react.defaults.DefaultReactNativeHost +import com.facebook.soloader.SoLoader + +class MainApplication : Application(), ReactApplication { + + override val reactNativeHost: ReactNativeHost = + object : DefaultReactNativeHost(this) { + override fun getPackages(): List = + PackageList(this).packages.apply { + // Packages that cannot be autolinked yet can be added manually here, for example: + // add(MyReactNativePackage()) + } + + override fun getJSMainModuleName(): String = "index" + + override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG + + override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED + override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED + } + + override val reactHost: ReactHost + get() = getDefaultReactHost(applicationContext, reactNativeHost) + + override fun onCreate() { + super.onCreate() + SoLoader.init(this, false) + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + // If you opted-in for the New Architecture, we load the native entry point for this app. + load() + } + } +} diff --git a/examples/sdk/reactNative/android/app/src/main/res/drawable/rn_edit_text_material.xml b/examples/sdk/reactNative/android/app/src/main/res/drawable/rn_edit_text_material.xml index 73b37e4d..5c25e728 100644 --- a/examples/sdk/reactNative/android/app/src/main/res/drawable/rn_edit_text_material.xml +++ b/examples/sdk/reactNative/android/app/src/main/res/drawable/rn_edit_text_material.xml @@ -17,7 +17,8 @@ android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material" android:insetRight="@dimen/abc_edit_text_inset_horizontal_material" android:insetTop="@dimen/abc_edit_text_inset_top_material" - android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"> + android:insetBottom="@dimen/abc_edit_text_inset_bottom_material" + > + NSAllowsArbitraryLoads + + NSAllowsLocalNetworking + NSLocationWhenInUseUsageDescription @@ -41,7 +38,7 @@ LaunchScreen UIRequiredDeviceCapabilities - armv7 + arm64 UISupportedInterfaceOrientations diff --git a/examples/sdk/reactNative/ios/reactNative/LaunchScreen.storyboard b/examples/sdk/reactNative/ios/rnbtexample/LaunchScreen.storyboard similarity index 98% rename from examples/sdk/reactNative/ios/reactNative/LaunchScreen.storyboard rename to examples/sdk/reactNative/ios/rnbtexample/LaunchScreen.storyboard index 80429b58..d6d27453 100644 --- a/examples/sdk/reactNative/ios/reactNative/LaunchScreen.storyboard +++ b/examples/sdk/reactNative/ios/rnbtexample/LaunchScreen.storyboard @@ -16,7 +16,7 @@ -