Skip to content

Commit 01cbd45

Browse files
authored
chore: upgrade iMessageClone react native version to 0.69.5 and related maintenance (#38)
* chore: upgrade iMessageClone react native version to 0.69.5 and related maintenance * chore: upgrade @types/react-test-renderer to appropriate version 18.0.0
1 parent e308a45 commit 01cbd45

Some content is hidden

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

42 files changed

+3904
-3144
lines changed

projects/iMessageClone/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23+
ios/.xcode.env.local
2324

2425
# Android/IntelliJ
2526
#
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [],
9+
"macFrameworkPath": [
10+
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
11+
],
12+
"compilerPath": "/usr/bin/clang",
13+
"cStandard": "c17",
14+
"cppStandard": "c++17",
15+
"intelliSenseMode": "macos-clang-x64"
16+
}
17+
],
18+
"version": 4
19+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "interactive",
3+
"files.associations": {
4+
"__bit_reference": "cpp",
5+
"__bits": "cpp",
6+
"__config": "cpp",
7+
"__debug": "cpp",
8+
"__errc": "cpp",
9+
"__hash_table": "cpp",
10+
"__locale": "cpp",
11+
"__mutex_base": "cpp",
12+
"__node_handle": "cpp",
13+
"__nullptr": "cpp",
14+
"__split_buffer": "cpp",
15+
"__string": "cpp",
16+
"__threading_support": "cpp",
17+
"__tree": "cpp",
18+
"__tuple": "cpp",
19+
"array": "cpp",
20+
"atomic": "cpp",
21+
"bit": "cpp",
22+
"bitset": "cpp",
23+
"cctype": "cpp",
24+
"chrono": "cpp",
25+
"cinttypes": "cpp",
26+
"clocale": "cpp",
27+
"cmath": "cpp",
28+
"compare": "cpp",
29+
"complex": "cpp",
30+
"concepts": "cpp",
31+
"cstdarg": "cpp",
32+
"cstddef": "cpp",
33+
"cstdint": "cpp",
34+
"cstdio": "cpp",
35+
"cstdlib": "cpp",
36+
"cstring": "cpp",
37+
"ctime": "cpp",
38+
"cwchar": "cpp",
39+
"cwctype": "cpp",
40+
"deque": "cpp",
41+
"exception": "cpp",
42+
"coroutine": "cpp",
43+
"initializer_list": "cpp",
44+
"ios": "cpp",
45+
"iosfwd": "cpp",
46+
"istream": "cpp",
47+
"limits": "cpp",
48+
"locale": "cpp",
49+
"map": "cpp",
50+
"memory": "cpp",
51+
"mutex": "cpp",
52+
"new": "cpp",
53+
"optional": "cpp",
54+
"ostream": "cpp",
55+
"ratio": "cpp",
56+
"shared_mutex": "cpp",
57+
"sstream": "cpp",
58+
"stdexcept": "cpp",
59+
"streambuf": "cpp",
60+
"string": "cpp",
61+
"string_view": "cpp",
62+
"system_error": "cpp",
63+
"thread": "cpp",
64+
"tuple": "cpp",
65+
"type_traits": "cpp",
66+
"typeinfo": "cpp",
67+
"unordered_map": "cpp",
68+
"unordered_set": "cpp",
69+
"variant": "cpp",
70+
"vector": "cpp",
71+
"__functional_base": "cpp",
72+
"algorithm": "cpp",
73+
"functional": "cpp",
74+
"iterator": "cpp",
75+
"utility": "cpp"
76+
}
77+
}

projects/iMessageClone/App.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {NewMessageProvider} from './src/contexts/NewMessageContext';
1414
import {Channel as ChannelType} from 'stream-chat';
1515
import {useStreamChatTheme} from './useStreamChatTheme';
1616
import {chatClient, user, userToken} from './src/client';
17+
import {GestureHandlerRootView} from 'react-native-gesture-handler';
1718

1819
type State = {
1920
channel?: ChannelType;
@@ -61,17 +62,19 @@ const App = () => {
6162
<AppContext.Provider
6263
value={{channel, setChannel, chatClient, setChannelWithId, messageId}}>
6364
<SearchContextProvider>
64-
<OverlayProvider bottomInset={bottom} value={{style: theme}}>
65-
<ThemeProvider style={theme}>
66-
{clientReady && (
67-
<NewMessageProvider>
68-
<Chat client={chatClient}>
69-
<Screens />
70-
</Chat>
71-
</NewMessageProvider>
72-
)}
73-
</ThemeProvider>
74-
</OverlayProvider>
65+
<GestureHandlerRootView style={{flex: 1}}>
66+
<OverlayProvider bottomInset={bottom} value={{style: theme}}>
67+
<ThemeProvider style={theme}>
68+
{clientReady && (
69+
<NewMessageProvider>
70+
<Chat client={chatClient}>
71+
<Screens />
72+
</Chat>
73+
</NewMessageProvider>
74+
)}
75+
</ThemeProvider>
76+
</OverlayProvider>
77+
</GestureHandlerRootView>
7578
</SearchContextProvider>
7679
</AppContext.Provider>
7780
</NavigationContainer>

projects/iMessageClone/android/app/build.gradle

Lines changed: 131 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,102 @@ def jscFlavor = 'org.webkit:android-jsc:+'
120120
*/
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123+
/**
124+
* Architectures to build native code for.
125+
*/
126+
def reactNativeArchitectures() {
127+
def value = project.getProperties().get("reactNativeArchitectures")
128+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
129+
}
130+
123131
android {
124132
ndkVersion rootProject.ext.ndkVersion
125133

126134
compileSdkVersion rootProject.ext.compileSdkVersion
127135

128-
compileOptions {
129-
sourceCompatibility JavaVersion.VERSION_1_8
130-
targetCompatibility JavaVersion.VERSION_1_8
131-
}
132-
133136
defaultConfig {
134137
applicationId "io.getstream.reactnative.imessageclone"
135138
minSdkVersion rootProject.ext.minSdkVersion
136139
targetSdkVersion rootProject.ext.targetSdkVersion
137140
versionCode 1
138141
versionName "1.0"
142+
143+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144+
145+
if (isNewArchitectureEnabled()) {
146+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
147+
externalNativeBuild {
148+
ndkBuild {
149+
arguments "APP_PLATFORM=android-21",
150+
"APP_STL=c++_shared",
151+
"NDK_TOOLCHAIN_VERSION=clang",
152+
"GENERATED_SRC_DIR=$buildDir/generated/source",
153+
"PROJECT_BUILD_DIR=$buildDir",
154+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
155+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
156+
"NODE_MODULES_DIR=$rootDir/../node_modules"
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 "imessageclone_appmodules"
162+
}
163+
}
164+
if (!enableSeparateBuildPerCPUArchitecture) {
165+
ndk {
166+
abiFilters (*reactNativeArchitectures())
167+
}
168+
}
169+
}
139170
}
171+
172+
if (isNewArchitectureEnabled()) {
173+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
174+
externalNativeBuild {
175+
ndkBuild {
176+
path "$projectDir/src/main/jni/Android.mk"
177+
}
178+
}
179+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
180+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
181+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
182+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
183+
into("$buildDir/react-ndk/exported")
184+
}
185+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
186+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
187+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
188+
into("$buildDir/react-ndk/exported")
189+
}
190+
afterEvaluate {
191+
// If you wish to add a custom TurboModule or component locally,
192+
// you should uncomment this line.
193+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
194+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
195+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
196+
197+
// Due to a bug inside AGP, we have to explicitly set a dependency
198+
// between configureNdkBuild* tasks and the preBuild tasks.
199+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
200+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
201+
configureNdkBuildDebug.dependsOn(preDebugBuild)
202+
reactNativeArchitectures().each { architecture ->
203+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
204+
dependsOn("preDebugBuild")
205+
}
206+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
207+
dependsOn("preReleaseBuild")
208+
}
209+
}
210+
}
211+
}
212+
140213
splits {
141214
abi {
142215
reset()
143216
enable enableSeparateBuildPerCPUArchitecture
144217
universalApk false // If true, also generate a universal APK
145-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
218+
include (*reactNativeArchitectures())
146219
}
147220
}
148221
signingConfigs {
@@ -155,32 +228,32 @@ android {
155228
}
156229
buildTypes {
157230
debug {
158-
signingConfig signingConfigs.debug
159-
}
160-
release {
161-
// Caution! In production, you need to generate your own keystore file.
162-
// see https://reactnative.dev/docs/signed-apk-android.
163-
signingConfig signingConfigs.debug
164-
minifyEnabled enableProguardInReleaseBuilds
165-
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
166-
}
231+
signingConfig signingConfigs.debug
232+
}
233+
release {
234+
// Caution! In production, you need to generate your own keystore file.
235+
// see https://reactnative.dev/docs/signed-apk-android.
236+
signingConfig signingConfigs.debug
237+
minifyEnabled enableProguardInReleaseBuilds
238+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
239+
}
167240
}
168241

169-
// applicationVariants are e.g. debug, release
170-
applicationVariants.all { variant ->
171-
variant.outputs.each { output ->
172-
// For each separate APK per architecture, set a unique version code as described here:
173-
// https://developer.android.com/studio/build/configure-apk-splits.html
174-
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
175-
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
176-
def abi = output.getFilter(OutputFile.ABI)
177-
if (abi != null) { // null for the universal-debug, universal-release variants
178-
output.versionCodeOverride =
179-
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
180-
}
242+
// applicationVariants are e.g. debug, release
243+
applicationVariants.all { variant ->
244+
variant.outputs.each { output ->
245+
// For each separate APK per architecture, set a unique version code as described here:
246+
// https://developer.android.com/studio/build/configure-apk-splits.html
247+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
248+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
249+
def abi = output.getFilter(OutputFile.ABI)
250+
if (abi != null) { // null for the universal-debug, universal-release variants
251+
output.versionCodeOverride =
252+
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
253+
}
181254

182-
}
183-
}
255+
}
256+
}
184257
}
185258

186259
dependencies {
@@ -204,19 +277,44 @@ dependencies {
204277
}
205278

206279
if (enableHermes) {
207-
def hermesPath = "../../node_modules/hermes-engine/android/";
208-
debugImplementation files(hermesPath + "hermes-debug.aar")
209-
releaseImplementation files(hermesPath + "hermes-release.aar")
280+
//noinspection GradleDynamicVersion
281+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
282+
exclude group: 'com.facebook.fbjni'
283+
}
210284
} else {
211285
implementation jscFlavor
212286
}
213287
}
214288

289+
if (isNewArchitectureEnabled()) {
290+
// If new architecture is enabled, we let you build RN from source
291+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
292+
// This will be applied to all the imported transtitive dependency.
293+
configurations.all {
294+
resolutionStrategy.dependencySubstitution {
295+
substitute(module("com.facebook.react:react-native"))
296+
.using(project(":ReactAndroid"))
297+
.because("On New Architecture we're building React Native from source")
298+
substitute(module("com.facebook.react:hermes-engine"))
299+
.using(project(":ReactAndroid:hermes-engine"))
300+
.because("On New Architecture we're building Hermes from source")
301+
}
302+
}
303+
}
304+
215305
// Run this once to be able to run the application with BUCK
216306
// puts all compile dependencies into folder libs for BUCK to use
217307
task copyDownloadableDepsToLibs(type: Copy) {
218-
from configurations.compile
308+
from configurations.implementation
219309
into 'libs'
220310
}
221311

222312
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
313+
314+
def isNewArchitectureEnabled() {
315+
// To opt-in for the New Architecture, you can either:
316+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
317+
// - Invoke gradle with `-newArchEnabled=true`
318+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
319+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
320+
}
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
43

5-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
65
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
7-
<application
8-
android:usesCleartextTraffic="true"
9-
tools:targetApi="28"
10-
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
6+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning">
7+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
128
</application>
13-
</manifest>
9+
</manifest>

0 commit comments

Comments
 (0)