From e6edefc93b8888810da91f66b1da527a0c22239b Mon Sep 17 00:00:00 2001
From: Radek Czemerys <7029942+radko93@users.noreply.github.com>
Date: Tue, 29 Mar 2022 08:53:50 +0100
Subject: [PATCH] feat: bump to 0.68.0-rc.4 (#258)
---
template/.bundle/config | 2 -
template/.ruby-version | 1 -
template/Gemfile | 2 +
template/Gemfile.lock | 10 +-
template/_bundle/config | 2 +
template/_gitignore | 3 +-
template/_prettierrc.js | 4 +-
template/_ruby-version | 1 +
template/android/app/build.gradle | 98 ++++++-
.../android/app/src/debug/AndroidManifest.xml | 2 +-
.../com/helloworld/ReactNativeFlipper.java | 5 +-
.../android/app/src/main/AndroidManifest.xml | 5 +-
.../java/com/helloworld/MainActivity.java | 25 ++
.../java/com/helloworld/MainApplication.java | 13 +-
.../MainApplicationReactNativeHost.java | 116 ++++++++
.../components/MainComponentsRegistry.java | 36 +++
...ApplicationTurboModuleManagerDelegate.java | 48 ++++
template/android/app/src/main/jni/Android.mk | 49 ++++
.../jni/MainApplicationModuleProvider.cpp | 24 ++
.../main/jni/MainApplicationModuleProvider.h | 16 ++
...nApplicationTurboModuleManagerDelegate.cpp | 45 +++
...ainApplicationTurboModuleManagerDelegate.h | 38 +++
.../src/main/jni/MainComponentsRegistry.cpp | 61 +++++
.../app/src/main/jni/MainComponentsRegistry.h | 32 +++
template/android/app/src/main/jni/OnLoad.cpp | 11 +
.../res/drawable/rn_edit_text_material.xml | 9 +-
template/android/build.gradle | 10 +-
template/android/gradle.properties | 18 +-
.../android/gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59536 bytes
.../gradle/wrapper/gradle-wrapper.properties | 2 +-
template/android/gradlew | 257 +++++++++++-------
template/android/settings.gradle | 6 +
.../ios/HelloWorld.xcodeproj/project.pbxproj | 135 ++++-----
template/ios/HelloWorld/AppDelegate.m | 62 -----
template/ios/HelloWorld/AppDelegate.mm | 108 ++++++++
.../AppIcon.appiconset/Contents.json | 45 ++-
template/ios/HelloWorld/main.m | 3 +-
.../ios/HelloWorldTests/HelloWorldTests.m | 27 +-
template/ios/Podfile | 11 +-
template/package.json | 12 +-
40 files changed, 1057 insertions(+), 297 deletions(-)
delete mode 100644 template/.bundle/config
delete mode 100644 template/.ruby-version
create mode 100644 template/_bundle/config
create mode 100644 template/_ruby-version
create mode 100644 template/android/app/src/main/java/com/helloworld/newarchitecture/MainApplicationReactNativeHost.java
create mode 100644 template/android/app/src/main/java/com/helloworld/newarchitecture/components/MainComponentsRegistry.java
create mode 100644 template/android/app/src/main/java/com/helloworld/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
create mode 100644 template/android/app/src/main/jni/Android.mk
create mode 100644 template/android/app/src/main/jni/MainApplicationModuleProvider.cpp
create mode 100644 template/android/app/src/main/jni/MainApplicationModuleProvider.h
create mode 100644 template/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp
create mode 100644 template/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h
create mode 100644 template/android/app/src/main/jni/MainComponentsRegistry.cpp
create mode 100644 template/android/app/src/main/jni/MainComponentsRegistry.h
create mode 100644 template/android/app/src/main/jni/OnLoad.cpp
delete mode 100644 template/ios/HelloWorld/AppDelegate.m
create mode 100644 template/ios/HelloWorld/AppDelegate.mm
diff --git a/template/.bundle/config b/template/.bundle/config
deleted file mode 100644
index d137d242..00000000
--- a/template/.bundle/config
+++ /dev/null
@@ -1,2 +0,0 @@
-BUNDLE_PATH: "vendor/bundle"
-BUNDLE_FORCE_RUBY_PLATFORM: 1
\ No newline at end of file
diff --git a/template/.ruby-version b/template/.ruby-version
deleted file mode 100644
index 74500cee..00000000
--- a/template/.ruby-version
+++ /dev/null
@@ -1 +0,0 @@
-2.7.4
\ No newline at end of file
diff --git a/template/Gemfile b/template/Gemfile
index c72a1ae2..2c3edcf4 100644
--- a/template/Gemfile
+++ b/template/Gemfile
@@ -1,4 +1,6 @@
source 'https://rubygems.org'
+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.4'
+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
diff --git a/template/Gemfile.lock b/template/Gemfile.lock
index b354433d..88c2fa28 100644
--- a/template/Gemfile.lock
+++ b/template/Gemfile.lock
@@ -45,7 +45,7 @@ GEM
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
- cocoapods-downloader (1.5.1)
+ cocoapods-downloader (1.6.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
@@ -54,7 +54,7 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
- concurrent-ruby (1.1.9)
+ concurrent-ruby (1.1.10)
escape (0.0.4)
ethon (0.15.0)
ffi (>= 1.15.0)
@@ -86,11 +86,15 @@ GEM
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
zeitwerk (2.5.4)
+
PLATFORMS
ruby
+
DEPENDENCIES
cocoapods (~> 1.11, >= 1.11.2)
+
RUBY VERSION
ruby 2.7.4p191
+
BUNDLED WITH
- 2.2.27
\ No newline at end of file
+ 2.2.27
diff --git a/template/_bundle/config b/template/_bundle/config
new file mode 100644
index 00000000..848943bb
--- /dev/null
+++ b/template/_bundle/config
@@ -0,0 +1,2 @@
+BUNDLE_PATH: "vendor/bundle"
+BUNDLE_FORCE_RUBY_PLATFORM: 1
diff --git a/template/_gitignore b/template/_gitignore
index cc53454e..81570d99 100644
--- a/template/_gitignore
+++ b/template/_gitignore
@@ -56,5 +56,6 @@ buck-out/
# Bundle artifact
*.jsbundle
-# CocoaPods
+# Ruby / CocoaPods
/ios/Pods/
+/vendor/bundle/
diff --git a/template/_prettierrc.js b/template/_prettierrc.js
index 84196d95..2b540746 100644
--- a/template/_prettierrc.js
+++ b/template/_prettierrc.js
@@ -1,7 +1,7 @@
module.exports = {
+ arrowParens: 'avoid',
+ bracketSameLine: true,
bracketSpacing: false,
- jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
- arrowParens: 'avoid',
};
diff --git a/template/_ruby-version b/template/_ruby-version
new file mode 100644
index 00000000..a4dd9dba
--- /dev/null
+++ b/template/_ruby-version
@@ -0,0 +1 @@
+2.7.4
diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle
index a461d9a9..a173c56b 100644
--- a/template/android/app/build.gradle
+++ b/template/android/app/build.gradle
@@ -121,9 +121,12 @@ def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
/**
- * Architectures to build native code for in debug.
+ * Architectures to build native code for.
*/
-def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
+def reactNativeArchitectures() {
+ def value = project.getProperties().get("reactNativeArchitectures")
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
+}
android {
ndkVersion rootProject.ext.ndkVersion
@@ -136,13 +139,76 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
+
+ if (isNewArchitectureEnabled()) {
+ // We configure the NDK build only if you decide to opt-in for the New Architecture.
+ externalNativeBuild {
+ ndkBuild {
+ arguments "APP_PLATFORM=android-21",
+ "APP_STL=c++_shared",
+ "NDK_TOOLCHAIN_VERSION=clang",
+ "GENERATED_SRC_DIR=$buildDir/generated/source",
+ "PROJECT_BUILD_DIR=$buildDir",
+ "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
+ "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
+ cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
+ cppFlags "-std=c++17"
+ // Make sure this target name is the same you specify inside the
+ // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
+ targets "helloworld_appmodules"
+ }
+ }
+ }
+ }
+
+ if (isNewArchitectureEnabled()) {
+ // We configure the NDK build only if you decide to opt-in for the New Architecture.
+ externalNativeBuild {
+ ndkBuild {
+ path "$projectDir/src/main/jni/Android.mk"
+ }
+ }
+ def reactAndroidProjectDir = project(':ReactAndroid').projectDir
+ def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
+ dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
+ from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
+ into("$buildDir/react-ndk/exported")
+ }
+ def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
+ dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
+ from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
+ into("$buildDir/react-ndk/exported")
+ }
+ afterEvaluate {
+ // If you wish to add a custom TurboModule or component locally,
+ // you should uncomment this line.
+ // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
+ preDebugBuild.dependsOn(packageReactNdkDebugLibs)
+ preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
+
+ // Due to a bug inside AGP, we have to explicitly set a dependency
+ // between configureNdkBuild* tasks and the preBuild tasks.
+ // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
+ configureNdkBuildRelease.dependsOn(preReleaseBuild)
+ configureNdkBuildDebug.dependsOn(preDebugBuild)
+ reactNativeArchitectures().each { architecture ->
+ tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
+ dependsOn("preDebugBuild")
+ }
+ tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
+ dependsOn("preReleaseBuild")
+ }
+ }
+ }
}
+
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
- include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
+ include (*reactNativeArchitectures())
}
}
signingConfigs {
@@ -156,11 +222,6 @@ android {
buildTypes {
debug {
signingConfig signingConfigs.debug
- if (nativeArchitectures) {
- ndk {
- abiFilters nativeArchitectures.split(',')
- }
- }
}
release {
// Caution! In production, you need to generate your own keystore file.
@@ -190,6 +251,7 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
+
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
@@ -217,6 +279,18 @@ dependencies {
}
}
+if (isNewArchitectureEnabled()) {
+ // If new architecture is enabled, we let you build RN from source
+ // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
+ // This will be applied to all the imported transtitive dependency.
+ configurations.all {
+ resolutionStrategy.dependencySubstitution {
+ substitute(module("com.facebook.react:react-native"))
+ .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
+ }
+ }
+}
+
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
@@ -225,3 +299,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
+
+def isNewArchitectureEnabled() {
+ // To opt-in for the New Architecture, you can either:
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
+ // - Invoke gradle with `-newArchEnabled=true`
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
+}
diff --git a/template/android/app/src/debug/AndroidManifest.xml b/template/android/app/src/debug/AndroidManifest.xml
index b2f3ad9f..4b185bc1 100644
--- a/template/android/app/src/debug/AndroidManifest.xml
+++ b/template/android/app/src/debug/AndroidManifest.xml
@@ -8,6 +8,6 @@
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
-
This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
@@ -19,6 +19,7 @@
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
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;
@@ -51,7 +52,7 @@ public void apply(OkHttpClient.Builder builder) {
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
reactInstanceManager.addReactInstanceEventListener(
- new ReactInstanceManager.ReactInstanceEventListener() {
+ new ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
diff --git a/template/android/app/src/main/AndroidManifest.xml b/template/android/app/src/main/AndroidManifest.xml
index 6db8bad3..7ba57ca1 100644
--- a/template/android/app/src/main/AndroidManifest.xml
+++ b/template/android/app/src/main/AndroidManifest.xml
@@ -13,9 +13,10 @@
Please note that this class is used ONLY if you opt-in for the New Architecture (see the
+ * `newArchEnabled` property). Is ignored otherwise.
+ */
+public class MainApplicationReactNativeHost extends ReactNativeHost {
+ public MainApplicationReactNativeHost(Application application) {
+ super(application);
+ }
+
+ @Override
+ public boolean getUseDeveloperSupport() {
+ return BuildConfig.DEBUG;
+ }
+
+ @Override
+ protected List Please note that this class is used ONLY if you opt-in for the New Architecture (see the
+ * `newArchEnabled` property). Is ignored otherwise.
+ */
+@DoNotStrip
+public class MainComponentsRegistry {
+ static {
+ SoLoader.loadLibrary("fabricjni");
+ }
+
+ @DoNotStrip private final HybridData mHybridData;
+
+ @DoNotStrip
+ private native HybridData initHybrid(ComponentFactory componentFactory);
+
+ @DoNotStrip
+ private MainComponentsRegistry(ComponentFactory componentFactory) {
+ mHybridData = initHybrid(componentFactory);
+ }
+
+ @DoNotStrip
+ public static MainComponentsRegistry register(ComponentFactory componentFactory) {
+ return new MainComponentsRegistry(componentFactory);
+ }
+}
diff --git a/template/android/app/src/main/java/com/helloworld/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java b/template/android/app/src/main/java/com/helloworld/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
new file mode 100644
index 00000000..8593b3bb
--- /dev/null
+++ b/template/android/app/src/main/java/com/helloworld/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
@@ -0,0 +1,48 @@
+package com.helloworld.newarchitecture.modules;
+
+import com.facebook.jni.HybridData;
+import com.facebook.react.ReactPackage;
+import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.soloader.SoLoader;
+import java.util.List;
+
+/**
+ * Class responsible to load the TurboModules. This class has native methods and needs a
+ * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
+ * folder for you).
+ *
+ * Please note that this class is used ONLY if you opt-in for the New Architecture (see the
+ * `newArchEnabled` property). Is ignored otherwise.
+ */
+public class MainApplicationTurboModuleManagerDelegate
+ extends ReactPackageTurboModuleManagerDelegate {
+
+ private static volatile boolean sIsSoLibraryLoaded;
+
+ protected MainApplicationTurboModuleManagerDelegate(
+ ReactApplicationContext reactApplicationContext, List syE_V_3M&trw$P=ezkHosV$8&I5c0(*-9KBE5DJOC-Xv
zw dQs=^
z@xwZQU)~;p1L*~ciC}9ao{nQ-@B>r s&&O3h=OLiCz&(|f0
zxWU_-JZy>hxP*gvR>CLnNeQ1~g;6{g#-}AbkIzWR;j=8=6!AHpKQCbjFYxf9h%bov
zVi;eNa1>t-<14KERUW>^KwoF+8zNo`4
zYYc!v@NU%|U;_sM`2z(4BAilWijmR>4U^KdN)D8%@2KLcqkTDW%^3U(Wg>{qkAF
z&RcYr;D1I5aD(N-PnqoEeBN~JyXiT(+@b`4Pv`;KmkBXYN48@0;iXuq6!ytn`vGp$
z6X4DQHMx^WlOek^bde&~cvEO@K$oJ}i`T`N;M|lX0mhmEHPrXXW>6X}+73IoMsu2?uuK3lT>;W
EGPXy}XK_&x597
zt(o6ArN8vZX0?~(lFGHRtHP{gO0y^$iU6Xt2e&v&ugLxfsl;GD)nf~3R^ACqSFLQ<
zV7`cXgry((wDMJB55a6