Skip to content

Commit 24968f3

Browse files
committed
feat: update react native 0.68
1 parent 1173eef commit 24968f3

Some content is hidden

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

61 files changed

+9943
-9466
lines changed

.gitignore

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

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
It is a template that you can clone and reuse for every project. It is starting point for React Native application.
88

9-
## React Native Boilerplate ( 0.67.3 )
9+
## React Native Boilerplate ( 0.68.0 )
1010

1111
consist of:
1212

13-
- react-native": "0.67.3"
13+
- react-native": "0.68.0"
1414
- react-navigation and its dependencies: -> React navigation 6.
15-
- @react-navigation/native: "^6.0.8
16-
- @react-navigation/native-stack: "^6.5.0"
17-
- @react-navigation/stack: "^6.1.1"
18-
- react-native-gesture-handler: "^2.2.0"
19-
- react-native-screens: "^3.13.0"
15+
- @react-navigation/native: "^6.0.10
16+
- @react-navigation/native-stack: "^6.6.1"
17+
- @react-navigation/stack: "^6.2.1"
18+
- react-native-gesture-handler: "^2.3.2"
19+
- react-native-screens: "^3.13.1"
2020
- react-native-tab-view: "^3.1.1"
2121
- react-native-masked-view/masked-view: "^0.2.6"
2222
- @react-navigation/bottom-tabs: "^6.2.0"
2323
- @react-navigation/material-top-tabs: "^6.1.1"
24-
- redux -> new reduxjs/toolkit : ^1.8.0
24+
- redux -> new reduxjs/toolkit : "^1.8.1"
2525
- react native vector icons: "^9.1.0"
2626

2727
## Requirements

template/.flowconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ node_modules/react-native/Libraries/polyfills/.*
1111
; Flow doesn't support platforms
1212
.*/Libraries/Utilities/LoadingView.js
1313

14+
.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$
15+
1416
[untyped]
1517
.*/node_modules/@react-native-community/cli/.*/.*
1618

@@ -62,4 +64,4 @@ untyped-import
6264
untyped-type-import
6365

6466
[version]
65-
^0.162.0
67+
^0.170.0

template/.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ module.exports = {
66
bracketSpacing: true,
77
trailingComma: 'none',
88
arrowParens: 'avoid'
9-
}
9+
}

template/Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GEM
33
specs:
44
CFPropertyList (3.0.5)
55
rexml
6-
activesupport (6.1.4.6)
6+
activesupport (6.1.5)
77
concurrent-ruby (~> 1.0, >= 1.0.2)
88
i18n (>= 1.6, < 2)
99
minitest (>= 5.1)
@@ -16,10 +16,10 @@ GEM
1616
json (>= 1.5.1)
1717
atomos (0.1.3)
1818
claide (1.1.0)
19-
cocoapods (1.11.2)
19+
cocoapods (1.11.3)
2020
addressable (~> 2.8)
2121
claide (>= 1.0.2, < 2.0)
22-
cocoapods-core (= 1.11.2)
22+
cocoapods-core (= 1.11.3)
2323
cocoapods-deintegrate (>= 1.0.3, < 2.0)
2424
cocoapods-downloader (>= 1.4.0, < 2.0)
2525
cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -34,7 +34,7 @@ GEM
3434
nap (~> 1.0)
3535
ruby-macho (>= 1.0, < 3.0)
3636
xcodeproj (>= 1.21.0, < 2.0)
37-
cocoapods-core (1.11.2)
37+
cocoapods-core (1.11.3)
3838
activesupport (>= 5.0, < 7)
3939
addressable (~> 2.8)
4040
algoliasearch (~> 1.0)
@@ -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.2)
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)

template/README.md

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

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 "reactnativeboilerplate_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) {
@@ -226,3 +300,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
226300

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

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/reactnativeboilerplate/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" />

0 commit comments

Comments
 (0)