Skip to content

Commit ed4628a

Browse files
Update RN to 0.69 and build from source on Android
1 parent 503cd54 commit ed4628a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+10746
-11706
lines changed

.bundle/config

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

.gitignore

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ DerivedData
2424
*.p12
2525
*.mobileprovision
2626
ios-fastlane-json-key.json
27+
ios/.xcode.env.local
2728

2829
# Android/IntelliJ
2930
#
@@ -62,15 +63,17 @@ android/app/android-fastlane-json-key.json
6263
# For more information about the recommended setup visit:
6364
# https://docs.fastlane.tools/best-practices/source-control/
6465

65-
fastlane/report.xml
66-
fastlane/Preview.html
67-
fastlane/screenshots
66+
**/fastlane/report.xml
67+
**/fastlane/Preview.html
68+
**/fastlane/screenshots
69+
**/fastlane/test_output
6870

6971
# Bundle artifact
7072
*.jsbundle
7173

72-
# CocoaPods
74+
# Ruby / CocoaPods
7375
/ios/Pods/
76+
/vendor/bundle/
7477

7578
# Local DEV config
7679
/.env

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source "https://rubygems.org"
22

3-
gem "cocoapods", "~> 1"
3+
gem "cocoapods", "~> 1.11.3"
44
gem "fastlane", "~> 2"
55
gem "xcpretty", "~> 0"

Gemfile.lock

+34-31
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
CFPropertyList (3.0.3)
5-
activesupport (5.2.4.4)
5+
activesupport (6.1.6)
66
concurrent-ruby (~> 1.0, >= 1.0.2)
7-
i18n (>= 0.7, < 2)
8-
minitest (~> 5.1)
9-
tzinfo (~> 1.1)
7+
i18n (>= 1.6, < 2)
8+
minitest (>= 5.1)
9+
tzinfo (~> 2.0)
10+
zeitwerk (~> 2.3)
1011
addressable (2.8.0)
1112
public_suffix (>= 2.0.2, < 5.0)
1213
algoliasearch (1.27.5)
@@ -32,10 +33,10 @@ GEM
3233
aws-eventstream (~> 1, >= 1.0.2)
3334
babosa (1.0.4)
3435
claide (1.0.3)
35-
cocoapods (1.10.1)
36-
addressable (~> 2.6)
36+
cocoapods (1.11.3)
37+
addressable (~> 2.8)
3738
claide (>= 1.0.2, < 2.0)
38-
cocoapods-core (= 1.10.1)
39+
cocoapods-core (= 1.11.3)
3940
cocoapods-deintegrate (>= 1.0.3, < 2.0)
4041
cocoapods-downloader (>= 1.4.0, < 2.0)
4142
cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -46,34 +47,34 @@ GEM
4647
escape (~> 0.0.4)
4748
fourflusher (>= 2.3.0, < 3.0)
4849
gh_inspector (~> 1.0)
49-
molinillo (~> 0.6.6)
50+
molinillo (~> 0.8.0)
5051
nap (~> 1.0)
51-
ruby-macho (~> 1.4)
52-
xcodeproj (>= 1.19.0, < 2.0)
53-
cocoapods-core (1.10.1)
54-
activesupport (> 5.0, < 6)
55-
addressable (~> 2.6)
52+
ruby-macho (>= 1.0, < 3.0)
53+
xcodeproj (>= 1.21.0, < 2.0)
54+
cocoapods-core (1.11.3)
55+
activesupport (>= 5.0, < 7)
56+
addressable (~> 2.8)
5657
algoliasearch (~> 1.0)
5758
concurrent-ruby (~> 1.1)
5859
fuzzy_match (~> 2.0.4)
5960
nap (~> 1.0)
6061
netrc (~> 0.11)
61-
public_suffix
62+
public_suffix (~> 4.0)
6263
typhoeus (~> 1.0)
63-
cocoapods-deintegrate (1.0.4)
64-
cocoapods-downloader (1.4.0)
64+
cocoapods-deintegrate (1.0.5)
65+
cocoapods-downloader (1.6.3)
6566
cocoapods-plugins (1.0.0)
6667
nap
67-
cocoapods-search (1.0.0)
68-
cocoapods-trunk (1.5.0)
68+
cocoapods-search (1.0.1)
69+
cocoapods-trunk (1.6.0)
6970
nap (>= 0.8, < 2.0)
7071
netrc (~> 0.11)
7172
cocoapods-try (1.2.0)
7273
colored (1.2)
7374
colored2 (3.1.2)
7475
commander (4.6.0)
7576
highline (~> 2.0.0)
76-
concurrent-ruby (1.1.7)
77+
concurrent-ruby (1.1.10)
7778
declarative (0.0.20)
7879
digest-crc (0.6.4)
7980
rake (>= 12.0.0, < 14.0.0)
@@ -82,8 +83,8 @@ GEM
8283
dotenv (2.7.6)
8384
emoji_regex (3.2.2)
8485
escape (0.0.4)
85-
ethon (0.12.0)
86-
ffi (>= 1.3.0)
86+
ethon (0.15.0)
87+
ffi (>= 1.15.0)
8788
excon (0.85.0)
8889
faraday (1.7.1)
8990
faraday-em_http (~> 1.0)
@@ -149,7 +150,7 @@ GEM
149150
xcodeproj (>= 1.13.0, < 2.0.0)
150151
xcpretty (~> 0.3.0)
151152
xcpretty-travis-formatter (>= 0.0.3)
152-
ffi (1.14.2)
153+
ffi (1.15.5)
153154
fourflusher (2.3.1)
154155
fuzzy_match (2.0.4)
155156
gh_inspector (1.1.3)
@@ -195,16 +196,16 @@ GEM
195196
http-cookie (1.0.4)
196197
domain_name (~> 0.5)
197198
httpclient (2.8.3)
198-
i18n (1.8.7)
199+
i18n (1.10.0)
199200
concurrent-ruby (~> 1.0)
200201
jmespath (1.4.0)
201202
json (2.5.1)
202203
jwt (2.2.3)
203204
memoist (0.16.2)
204205
mini_magick (4.11.0)
205206
mini_mime (1.1.1)
206-
minitest (5.14.3)
207-
molinillo (0.6.6)
207+
minitest (5.16.2)
208+
molinillo (0.8.0)
208209
multi_json (1.15.0)
209210
multipart-post (2.0.0)
210211
nanaimo (0.3.0)
@@ -223,7 +224,7 @@ GEM
223224
retriable (3.1.2)
224225
rexml (3.2.5)
225226
rouge (2.0.7)
226-
ruby-macho (1.4.0)
227+
ruby-macho (2.5.1)
227228
ruby2_keywords (0.0.5)
228229
rubyzip (2.3.2)
229230
security (0.1.3)
@@ -238,16 +239,15 @@ GEM
238239
terminal-notifier (2.0.0)
239240
terminal-table (1.8.0)
240241
unicode-display_width (~> 1.1, >= 1.1.1)
241-
thread_safe (0.3.6)
242242
trailblazer-option (0.1.1)
243243
tty-cursor (0.7.1)
244244
tty-screen (0.8.1)
245245
tty-spinner (0.9.3)
246246
tty-cursor (~> 0.7)
247247
typhoeus (1.4.0)
248248
ethon (>= 0.9.0)
249-
tzinfo (1.2.9)
250-
thread_safe (~> 0.1)
249+
tzinfo (2.0.4)
250+
concurrent-ruby (~> 1.0)
251251
uber (0.1.0)
252252
unf (0.1.4)
253253
unf_ext
@@ -266,16 +266,19 @@ GEM
266266
rouge (~> 2.0.7)
267267
xcpretty-travis-formatter (1.0.1)
268268
xcpretty (~> 0.2, >= 0.0.7)
269+
zeitwerk (2.6.0)
269270

270271
PLATFORMS
272+
arm64-darwin-21
273+
ruby
271274
universal-darwin-20
272275
x86_64-darwin-19
273276
x86_64-linux
274277

275278
DEPENDENCIES
276-
cocoapods (~> 1)
279+
cocoapods (~> 1.11.3)
277280
fastlane (~> 2)
278281
xcpretty (~> 0)
279282

280283
BUNDLED WITH
281-
2.3.16
284+
2.3.9

android/app/build.gradle

+103-12
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,19 @@ def jscFlavor = 'org.webkit:android-jsc:+'
121121
/**
122122
* Whether to enable the Hermes VM.
123123
*
124-
* This should be set on project.ext.react and mirrored here. If it is not set
124+
* This should be set on project.ext.react and that value will be read here. If it is not set
125125
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
126126
* and the benefits of using Hermes will therefore be sharply reduced.
127127
*/
128128
def enableHermes = project.ext.react.get("enableHermes", false);
129129

130130
/**
131-
* Required in order to build native code for debug builds
131+
* Architectures to build native code for.
132132
*/
133-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
133+
def reactNativeArchitectures() {
134+
def value = project.getProperties().get("reactNativeArchitectures")
135+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
136+
}
134137

135138
android {
136139
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -154,13 +157,81 @@ android {
154157
multiDexEnabled rootProject.ext.multiDexEnabled
155158
versionCode 1001018803
156159
versionName "1.1.88-3"
160+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
161+
162+
if (isNewArchitectureEnabled()) {
163+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
164+
externalNativeBuild {
165+
ndkBuild {
166+
arguments "APP_PLATFORM=android-21",
167+
"APP_STL=c++_shared",
168+
"NDK_TOOLCHAIN_VERSION=clang",
169+
"GENERATED_SRC_DIR=$buildDir/generated/source",
170+
"PROJECT_BUILD_DIR=$buildDir",
171+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
172+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
173+
"NODE_MODULES_DIR=$rootDir/../node_modules"
174+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
175+
cppFlags "-std=c++17"
176+
// Make sure this target name is the same you specify inside the
177+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
178+
targets "rndiffapp_appmodules"
179+
}
180+
}
181+
if (!enableSeparateBuildPerCPUArchitecture) {
182+
ndk {
183+
abiFilters (*reactNativeArchitectures())
184+
}
185+
}
186+
}
157187
}
188+
189+
if (isNewArchitectureEnabled()) {
190+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
191+
externalNativeBuild {
192+
ndkBuild {
193+
path "$projectDir/src/main/jni/Android.mk"
194+
}
195+
}
196+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
197+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
198+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
199+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
200+
into("$buildDir/react-ndk/exported")
201+
}
202+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
203+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
204+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
205+
into("$buildDir/react-ndk/exported")
206+
}
207+
afterEvaluate {
208+
// If you wish to add a custom TurboModule or component locally,
209+
// you should uncomment this line.
210+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
211+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
212+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
213+
// Due to a bug inside AGP, we have to explicitly set a dependency
214+
// between configureNdkBuild* tasks and the preBuild tasks.
215+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
216+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
217+
configureNdkBuildDebug.dependsOn(preDebugBuild)
218+
reactNativeArchitectures().each { architecture ->
219+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
220+
dependsOn("preDebugBuild")
221+
}
222+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
223+
dependsOn("preReleaseBuild")
224+
}
225+
}
226+
}
227+
}
228+
158229
splits {
159230
abi {
160231
reset()
161232
enable enableSeparateBuildPerCPUArchitecture
162233
universalApk false // If true, also generate a universal APK
163-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
234+
include (*reactNativeArchitectures())
164235
}
165236
}
166237
signingConfigs {
@@ -182,11 +253,6 @@ android {
182253
buildTypes {
183254
debug {
184255
signingConfig signingConfigs.debug
185-
if (nativeArchitectures) {
186-
ndk {
187-
abiFilters nativeArchitectures.split(',')
188-
}
189-
}
190256
}
191257
release {
192258
signingConfig signingConfigs.release
@@ -213,6 +279,7 @@ android {
213279

214280
dependencies {
215281
implementation fileTree(dir: "libs", include: ["*.jar"])
282+
216283
//noinspection GradleDynamicVersion
217284
implementation "com.facebook.react:react-native:+" // From node_modules
218285

@@ -232,9 +299,10 @@ dependencies {
232299
}
233300

234301
if (enableHermes) {
235-
def hermesPath = "../../node_modules/hermes-engine/android/";
236-
debugImplementation files(hermesPath + "hermes-debug.aar")
237-
releaseImplementation files(hermesPath + "hermes-release.aar")
302+
//noinspection GradleDynamicVersion
303+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
304+
exclude group:'com.facebook.fbjni'
305+
}
238306
} else {
239307
implementation jscFlavor
240308
}
@@ -260,6 +328,22 @@ dependencies {
260328
implementation "com.squareup.okhttp3:okhttp-urlconnection:4.+"
261329
}
262330

331+
if (isNewArchitectureEnabled()) {
332+
// If new architecture is enabled, we let you build RN from source
333+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
334+
// This will be applied to all the imported transtitive dependency.
335+
configurations.all {
336+
resolutionStrategy.dependencySubstitution {
337+
substitute(module("com.facebook.react:react-native"))
338+
.using(project(":ReactAndroid"))
339+
.because("On New Architecture we're building React Native from source")
340+
substitute(module("com.facebook.react:hermes-engine"))
341+
.using(project(":ReactAndroid:hermes-engine"))
342+
.because("On New Architecture we're building Hermes from source")
343+
}
344+
}
345+
}
346+
263347
// Run this once to be able to run the application with BUCK
264348
// puts all compile dependencies into folder libs for BUCK to use
265349
task copyDownloadableDepsToLibs(type: Copy) {
@@ -274,4 +358,11 @@ if (googleServicesFile.exists()) {
274358
}
275359
apply plugin: 'com.google.firebase.crashlytics'
276360

361+
def isNewArchitectureEnabled() {
362+
// To opt-in for the New Architecture, you can either:
363+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
364+
// - Invoke gradle with `-newArchEnabled=true`
365+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
366+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
367+
}
277368

android/app/src/debug/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
android:name="firebase_performance_logcat_enabled"
1010
android:value="true"
1111
/>
12+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
1213
</application>
1314
</manifest>

0 commit comments

Comments
 (0)