Skip to content

Commit ef22d28

Browse files
committed
Upgraded to React-Native 0.68.2 (new architecture), chore packages
1 parent 631de68 commit ef22d28

38 files changed

+1713
-882
lines changed

.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

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ android/app/src/main/assets/index.android.bundle
6666
ios/assets/src
6767
ios/assets/app.json
6868

69-
# CocoaPods
69+
# Ruby / CocoaPods
7070
/ios/Pods/
71+
/vendor/bundle/
7172

7273
# project
7374
.vscode/

.prettierrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
24
semi: true,
35
trailingComma: 'all',
46
singleQuote: true,
57
printWidth: 120,
68
bracketSpacing: true,
7-
arrowParens: 'avoid',
89
importOrder: ['<THIRD_PARTY_MODULES>', '^[./]'],
910
importOrderSeparation: false,
1011
};

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -71,7 +71,7 @@ GEM
7171
nanaimo (0.3.0)
7272
nap (1.1.0)
7373
netrc (0.11.0)
74-
public_suffix (4.0.6)
74+
public_suffix (4.0.7)
7575
rexml (3.2.5)
7676
ruby-macho (2.5.1)
7777
typhoeus (1.4.0)

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# React Native Redux Toolkit Start App <!-- omit in toc -->
1+
# React Native Redux Toolkit Start App <!-- omit in toc -->
22

33
> A React Native boilerplate app to bootstrap your next app wit Redux Toolkit and Saga!
44
5+
## 🔥🔥🔥 Upgraded to the latest React-Native (> 0.68.x) with brand New Architecture (Fabric) 🔥🔥🔥
6+
7+
<br/>
58
<div align="center">
69
<img src="./react-native-starter-kit.png" width="100%" />
710
</div>
@@ -24,6 +27,7 @@
2427

2528
# Table of Contents <!-- omit in toc -->
2629

30+
- [🔥🔥🔥 Upgraded to the latest React-Native (> 0.68.x) with brand New Architecture (Fabric) 🔥🔥🔥](#-upgraded-to-the-latest-react-native--068x-with-brand-new-architecture-fabric-)
2731
- [🔥🔥 Checkout also my brand new React Native React-Query (no redux toolkit) here 🔥🔥](#-checkout-also-my-brand-new-react-native-react-query-no-redux-toolkit-here-)
2832
- [Installation :inbox_tray:](#installation-inbox_tray)
2933
- [Rename project and bundles :memo: :package:](#rename-project-and-bundles-memo-package)
@@ -33,6 +37,7 @@
3337
- [Run the app](#run-the-app)
3438
- [Generate app icons](#generate-app-icons)
3539
- [Generate Splashscreen](#generate-splashscreen)
40+
- [To enabled React-Native (Fabric) new architecture](#to-enabled-react-native-fabric-new-architecture)
3641
- [Setup iOS](#setup-ios)
3742
- [Typescript (optional)](#typescript-optional)
3843
- [Roadmap :running:](#roadmap-running)
@@ -130,6 +135,10 @@ To setup the app splashscreen:
130135
yarn assets:splashscreen
131136
```
132137

138+
### To enabled React-Native (Fabric) new architecture
139+
140+
Check the official documentation [here](https://reactnative.dev/docs/new-architecture-intro)
141+
133142
### Setup iOS
134143

135144
To setup the environment to run on iOS, run
@@ -163,20 +172,20 @@ _REMEMBER: the entry point file in the root of the project MUST be index.js_
163172
## Roadmap :running:
164173

165174
✅ Initial Setup<br/>
166-
Add Splashscreen (https://github.com/crazycodeboy/react-native-splash-screen)<br/>
167-
Add Toolbox (https://github.com/panz3r/react-native-toolbox)<br/>
168-
Create tree folders structure<br/>
169-
Add `redux-toolkit`<br/>
170-
Add `redux-persist` (https://github.com/rt2zz/redux-persist)<br/>
171-
Add `React Native Debugger`<br/>
172-
Add `redux-saga`<br/>
173-
Add `i18next`<br/>
174-
Add `react-navigation v6` ❤️<br/>
175-
Add new UI Design System (`UIKitten v5`)<br />
176-
Add `Env` variables selection experimental way ⚗️⚗️⚗️<br />
177-
Add Typescript (optional use. Read the DOC above)<br />
178-
Add Travis<br />
179-
✅ Add DependaBot<br />
175+
`react-native-splashscreen` (https://github.com/crazycodeboy/react-native-splash-screen)<br/>
176+
`react-native-toolbox` to generate Splashscreen and icons automagically (https://github.com/panz3r/react-native-toolbox)<br/>
177+
Standard tree folders structure<br/>
178+
`React-Native 0.68.2 (new architecture)`<br/>
179+
`redux-toolkit`<br/>
180+
`redux-persist` (https://github.com/rt2zz/redux-persist)<br/>
181+
`React Native Debugger`<br/>
182+
`redux-saga`<br/>
183+
`i18next`<br/>
184+
`react-navigation v6` ❤️<br/>
185+
`UIKitten v5`<br />
186+
`Env` variables selection experimental way ⚗️⚗️⚗️<br />
187+
Typescript (optional use. Read the DOC above)<br />
188+
180189

181190
---
182191

android/app/build.gradle

Lines changed: 99 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
4+
import org.apache.tools.ant.taskdefs.condition.Os
45

56
/**
67
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -122,9 +123,12 @@ def jscFlavor = 'org.webkit:android-jsc:+'
122123
def enableHermes = project.ext.react.get("enableHermes", false);
123124

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

129133
android {
130134
ndkVersion rootProject.ext.ndkVersion
@@ -137,20 +141,85 @@ android {
137141
targetSdkVersion rootProject.ext.targetSdkVersion
138142
versionCode 1
139143
versionName "1.0"
140-
multiDexEnabled true
144+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
145+
146+
if (isNewArchitectureEnabled()) {
147+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
148+
externalNativeBuild {
149+
ndkBuild {
150+
arguments "APP_PLATFORM=android-21",
151+
"APP_STL=c++_shared",
152+
"NDK_TOOLCHAIN_VERSION=clang",
153+
"GENERATED_SRC_DIR=$buildDir/generated/source",
154+
"PROJECT_BUILD_DIR=$buildDir",
155+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
156+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
157+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
158+
cppFlags "-std=c++17"
159+
// Make sure this target name is the same you specify inside the
160+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
161+
targets "reactnativestarterapp_appmodules"
162+
163+
// Fix for windows limit on number of character in file paths and in command lines
164+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
165+
arguments "NDK_APP_SHORT_COMMANDS=true"
166+
}
167+
}
168+
}
169+
if (!enableSeparateBuildPerCPUArchitecture) {
170+
ndk {
171+
abiFilters (*reactNativeArchitectures())
172+
}
173+
}
174+
}
141175
}
142176

143-
dexOptions {
144-
incremental true
145-
javaMaxHeapSize "4g"
177+
if (isNewArchitectureEnabled()) {
178+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
179+
externalNativeBuild {
180+
ndkBuild {
181+
path "$projectDir/src/main/jni/Android.mk"
182+
}
183+
}
184+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
185+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
186+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
187+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
188+
into("$buildDir/react-ndk/exported")
189+
}
190+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
191+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
192+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
193+
into("$buildDir/react-ndk/exported")
194+
}
195+
afterEvaluate {
196+
// If you wish to add a custom TurboModule or component locally,
197+
// you should uncomment this line.
198+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
199+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
200+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
201+
// Due to a bug inside AGP, we have to explicitly set a dependency
202+
// between configureNdkBuild* tasks and the preBuild tasks.
203+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
204+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
205+
configureNdkBuildDebug.dependsOn(preDebugBuild)
206+
reactNativeArchitectures().each { architecture ->
207+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
208+
dependsOn("preDebugBuild")
209+
}
210+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
211+
dependsOn("preReleaseBuild")
212+
}
213+
}
214+
}
146215
}
147216

148217
splits {
149218
abi {
150219
reset()
151220
enable enableSeparateBuildPerCPUArchitecture
152221
universalApk true // If true, also generate a universal APK
153-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
222+
include (*reactNativeArchitectures())
154223
}
155224
}
156225
signingConfigs {
@@ -164,11 +233,6 @@ android {
164233
buildTypes {
165234
debug {
166235
signingConfig signingConfigs.debug
167-
if (nativeArchitectures) {
168-
ndk {
169-
abiFilters nativeArchitectures.split(',')
170-
}
171-
}
172236
}
173237
release {
174238
// Caution! In production, you need to generate your own keystore file.
@@ -198,8 +262,7 @@ android {
198262

199263
dependencies {
200264
implementation fileTree(dir: "libs", include: ["*.jar"])
201-
implementation project(':react-native-splash-screen')
202-
// implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
265+
203266
//noinspection GradleDynamicVersion
204267
implementation "com.facebook.react:react-native:+" // From node_modules
205268

@@ -217,6 +280,8 @@ dependencies {
217280
// For WebP support, without animations
218281
implementation 'com.facebook.fresco:webpsupport:2.6.0'
219282

283+
implementation project(':react-native-splash-screen')
284+
220285
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
221286
exclude group:'com.facebook.fbjni'
222287
}
@@ -239,6 +304,18 @@ dependencies {
239304
}
240305
}
241306

307+
if (isNewArchitectureEnabled()) {
308+
// If new architecture is enabled, we let you build RN from source
309+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
310+
// This will be applied to all the imported transtitive dependency.
311+
configurations.all {
312+
resolutionStrategy.dependencySubstitution {
313+
substitute(module("com.facebook.react:react-native"))
314+
.using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
315+
}
316+
}
317+
}
318+
242319
// Run this once to be able to run the application with BUCK
243320
// puts all compile dependencies into folder libs for BUCK to use
244321
task copyDownloadableDepsToLibs(type: Copy) {
@@ -247,3 +324,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
247324
}
248325

249326
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
327+
328+
def isNewArchitectureEnabled() {
329+
// To opt-in for the New Architecture, you can either:
330+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
331+
// - Invoke gradle with `-newArchEnabled=true`
332+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
333+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
334+
}

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>

android/app/src/debug/ReactNativeFlipper.java renamed to android/app/src/debug/java/com/reactnativestarterapp/ReactNativeFlipper.java

Lines changed: 7 additions & 3 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;
@@ -28,11 +29,13 @@ public class ReactNativeFlipper {
2829
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
2930
if (FlipperUtils.shouldEnableFlipper(context)) {
3031
final FlipperClient client = AndroidFlipperClient.getInstance(context);
32+
3133
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
3234
client.addPlugin(new ReactFlipperPlugin());
3335
client.addPlugin(new DatabasesFlipperPlugin(context));
3436
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
3537
client.addPlugin(CrashReporterPlugin.getInstance());
38+
3639
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
3740
NetworkingModule.setCustomClientBuilder(
3841
new NetworkingModule.CustomClientBuilder() {
@@ -43,12 +46,13 @@ public void apply(OkHttpClient.Builder builder) {
4346
});
4447
client.addPlugin(networkFlipperPlugin);
4548
client.start();
49+
4650
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
4751
// Hence we run if after all native modules have been initialized
4852
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
4953
if (reactContext == null) {
5054
reactInstanceManager.addReactInstanceEventListener(
51-
new ReactInstanceManager.ReactInstanceEventListener() {
55+
new ReactInstanceEventListener() {
5256
@Override
5357
public void onReactContextInitialized(ReactContext reactContext) {
5458
reactInstanceManager.removeReactInstanceEventListener(this);
@@ -66,4 +70,4 @@ public void run() {
6670
}
6771
}
6872
}
69-
}
73+
}

android/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
android:name=".SplashActivity"
1616
android:theme="@style/SplashTheme"
1717
android:label="@string/app_name"
18-
android:screenOrientation="portrait">
18+
android:screenOrientation="portrait"
19+
android:exported="true">
1920
<intent-filter>
2021
<action android:name="android.intent.action.MAIN" />
2122
<category android:name="android.intent.category.LAUNCHER" />
@@ -26,9 +27,10 @@
2627
<activity
2728
android:name=".MainActivity"
2829
android:label="@string/app_name"
29-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
30+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
3031
android:launchMode="singleTask"
31-
android:windowSoftInputMode="adjustResize">
32+
android:windowSoftInputMode="adjustResize"
33+
android:exported="true">
3234
<intent-filter>
3335
<action android:name="android.intent.action.VIEW" />
3436
<category android:name="android.intent.category.DEFAULT" />

0 commit comments

Comments
 (0)