Skip to content

Commit e6edefc

Browse files
authored
feat: bump to 0.68.0-rc.4 (#258)
1 parent ebe0776 commit e6edefc

40 files changed

+1057
-297
lines changed

template/.bundle/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

template/.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

template/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
source 'https://rubygems.org'
2+
23
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
34
ruby '2.7.4'
5+
46
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

template/Gemfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ GEM
4545
public_suffix (~> 4.0)
4646
typhoeus (~> 1.0)
4747
cocoapods-deintegrate (1.0.5)
48-
cocoapods-downloader (1.5.1)
48+
cocoapods-downloader (1.6.1)
4949
cocoapods-plugins (1.0.0)
5050
nap
5151
cocoapods-search (1.0.1)
@@ -54,7 +54,7 @@ GEM
5454
netrc (~> 0.11)
5555
cocoapods-try (1.2.0)
5656
colored2 (3.1.2)
57-
concurrent-ruby (1.1.9)
57+
concurrent-ruby (1.1.10)
5858
escape (0.0.4)
5959
ethon (0.15.0)
6060
ffi (>= 1.15.0)
@@ -86,11 +86,15 @@ GEM
8686
nanaimo (~> 0.3.0)
8787
rexml (~> 3.2.4)
8888
zeitwerk (2.5.4)
89+
8990
PLATFORMS
9091
ruby
92+
9193
DEPENDENCIES
9294
cocoapods (~> 1.11, >= 1.11.2)
95+
9396
RUBY VERSION
9497
ruby 2.7.4p191
98+
9599
BUNDLED WITH
96-
2.2.27
100+
2.2.27

template/_bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

template/_gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ buck-out/
5656
# Bundle artifact
5757
*.jsbundle
5858

59-
# CocoaPods
59+
# Ruby / CocoaPods
6060
/ios/Pods/
61+
/vendor/bundle/

template/_prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
24
bracketSpacing: false,
3-
jsxBracketSameLine: true,
45
singleQuote: true,
56
trailingComma: 'all',
6-
arrowParens: 'avoid',
77
};

template/_ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.4

template/android/app/build.gradle

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ def jscFlavor = 'org.webkit:android-jsc:+'
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123123
/**
124-
* Architectures to build native code for in debug.
124+
* Architectures to build native code for.
125125
*/
126-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
126+
def reactNativeArchitectures() {
127+
def value = project.getProperties().get("reactNativeArchitectures")
128+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
129+
}
127130

128131
android {
129132
ndkVersion rootProject.ext.ndkVersion
@@ -136,13 +139,76 @@ android {
136139
targetSdkVersion rootProject.ext.targetSdkVersion
137140
versionCode 1
138141
versionName "1.0"
142+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
143+
144+
if (isNewArchitectureEnabled()) {
145+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
146+
externalNativeBuild {
147+
ndkBuild {
148+
arguments "APP_PLATFORM=android-21",
149+
"APP_STL=c++_shared",
150+
"NDK_TOOLCHAIN_VERSION=clang",
151+
"GENERATED_SRC_DIR=$buildDir/generated/source",
152+
"PROJECT_BUILD_DIR=$buildDir",
153+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
154+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
155+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
156+
cppFlags "-std=c++17"
157+
// Make sure this target name is the same you specify inside the
158+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
159+
targets "helloworld_appmodules"
160+
}
161+
}
162+
}
163+
}
164+
165+
if (isNewArchitectureEnabled()) {
166+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
167+
externalNativeBuild {
168+
ndkBuild {
169+
path "$projectDir/src/main/jni/Android.mk"
170+
}
171+
}
172+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
173+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
174+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
175+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
176+
into("$buildDir/react-ndk/exported")
177+
}
178+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
179+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
180+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
181+
into("$buildDir/react-ndk/exported")
182+
}
183+
afterEvaluate {
184+
// If you wish to add a custom TurboModule or component locally,
185+
// you should uncomment this line.
186+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
187+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
188+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
189+
190+
// Due to a bug inside AGP, we have to explicitly set a dependency
191+
// between configureNdkBuild* tasks and the preBuild tasks.
192+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
193+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
194+
configureNdkBuildDebug.dependsOn(preDebugBuild)
195+
reactNativeArchitectures().each { architecture ->
196+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
197+
dependsOn("preDebugBuild")
198+
}
199+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
200+
dependsOn("preReleaseBuild")
201+
}
202+
}
203+
}
139204
}
205+
140206
splits {
141207
abi {
142208
reset()
143209
enable enableSeparateBuildPerCPUArchitecture
144210
universalApk false // If true, also generate a universal APK
145-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
211+
include (*reactNativeArchitectures())
146212
}
147213
}
148214
signingConfigs {
@@ -156,11 +222,6 @@ android {
156222
buildTypes {
157223
debug {
158224
signingConfig signingConfigs.debug
159-
if (nativeArchitectures) {
160-
ndk {
161-
abiFilters nativeArchitectures.split(',')
162-
}
163-
}
164225
}
165226
release {
166227
// Caution! In production, you need to generate your own keystore file.
@@ -190,6 +251,7 @@ android {
190251

191252
dependencies {
192253
implementation fileTree(dir: "libs", include: ["*.jar"])
254+
193255
//noinspection GradleDynamicVersion
194256
implementation "com.facebook.react:react-native:+" // From node_modules
195257

@@ -217,6 +279,18 @@ dependencies {
217279
}
218280
}
219281

282+
if (isNewArchitectureEnabled()) {
283+
// If new architecture is enabled, we let you build RN from source
284+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
285+
// This will be applied to all the imported transtitive dependency.
286+
configurations.all {
287+
resolutionStrategy.dependencySubstitution {
288+
substitute(module("com.facebook.react:react-native"))
289+
.using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
290+
}
291+
}
292+
}
293+
220294
// Run this once to be able to run the application with BUCK
221295
// puts all compile dependencies into folder libs for BUCK to use
222296
task copyDownloadableDepsToLibs(type: Copy) {
@@ -225,3 +299,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
225299
}
226300

227301
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
302+
303+
def isNewArchitectureEnabled() {
304+
// To opt-in for the New Architecture, you can either:
305+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
306+
// - Invoke gradle with `-newArchEnabled=true`
307+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
308+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
309+
}

template/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
android:usesCleartextTraffic="true"
99
tools:targetApi="28"
1010
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
11+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
1212
</application>
1313
</manifest>

template/android/app/src/debug/java/com/helloworld/ReactNativeFlipper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) Facebook, Inc. and its affiliates.
2+
* 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.
@@ -19,6 +19,7 @@
1919
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
2020
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
2121
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22+
import com.facebook.react.ReactInstanceEventListener;
2223
import com.facebook.react.ReactInstanceManager;
2324
import com.facebook.react.bridge.ReactContext;
2425
import com.facebook.react.modules.network.NetworkingModule;
@@ -51,7 +52,7 @@ public void apply(OkHttpClient.Builder builder) {
5152
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
5253
if (reactContext == null) {
5354
reactInstanceManager.addReactInstanceEventListener(
54-
new ReactInstanceManager.ReactInstanceEventListener() {
55+
new ReactInstanceEventListener() {
5556
@Override
5657
public void onReactContextInitialized(ReactContext reactContext) {
5758
reactInstanceManager.removeReactInstanceEventListener(this);

template/android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
<activity
1414
android:name=".MainActivity"
1515
android:label="@string/app_name"
16-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
1717
android:launchMode="singleTask"
18-
android:windowSoftInputMode="adjustResize">
18+
android:windowSoftInputMode="adjustResize"
19+
android:exported="true">
1920
<intent-filter>
2021
<action android:name="android.intent.action.MAIN" />
2122
<category android:name="android.intent.category.LAUNCHER" />

template/android/app/src/main/java/com/helloworld/MainActivity.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.helloworld;
22

33
import com.facebook.react.ReactActivity;
4+
import com.facebook.react.ReactActivityDelegate;
5+
import com.facebook.react.ReactRootView;
46

57
public class MainActivity extends ReactActivity {
68

@@ -12,4 +14,27 @@ public class MainActivity extends ReactActivity {
1214
protected String getMainComponentName() {
1315
return "HelloWorld";
1416
}
17+
18+
/**
19+
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
20+
* you can specify the rendered you wish to use (Fabric or the older renderer).
21+
*/
22+
@Override
23+
protected ReactActivityDelegate createReactActivityDelegate() {
24+
return new MainActivityDelegate(this, getMainComponentName());
25+
}
26+
27+
public static class MainActivityDelegate extends ReactActivityDelegate {
28+
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
29+
super(activity, mainComponentName);
30+
}
31+
32+
@Override
33+
protected ReactRootView createRootView() {
34+
ReactRootView reactRootView = new ReactRootView(getContext());
35+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
36+
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
37+
return reactRootView;
38+
}
39+
}
1540
}

template/android/app/src/main/java/com/helloworld/MainApplication.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import com.facebook.react.ReactInstanceManager;
88
import com.facebook.react.ReactNativeHost;
99
import com.facebook.react.ReactPackage;
10+
import com.facebook.react.config.ReactFeatureFlags;
1011
import com.facebook.soloader.SoLoader;
12+
import com.helloworld.newarchitecture.MainApplicationReactNativeHost;
1113
import java.lang.reflect.InvocationTargetException;
1214
import java.util.List;
1315

@@ -35,14 +37,23 @@ protected String getJSMainModuleName() {
3537
}
3638
};
3739

40+
private final ReactNativeHost mNewArchitectureNativeHost =
41+
new MainApplicationReactNativeHost(this);
42+
3843
@Override
3944
public ReactNativeHost getReactNativeHost() {
40-
return mReactNativeHost;
45+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
46+
return mNewArchitectureNativeHost;
47+
} else {
48+
return mReactNativeHost;
49+
}
4150
}
4251

4352
@Override
4453
public void onCreate() {
4554
super.onCreate();
55+
// If you opted-in for the New Architecture, we enable the TurboModule system
56+
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
4657
SoLoader.init(this, /* native exopackage */ false);
4758
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
4859
}

0 commit comments

Comments
 (0)