Skip to content

Commit 3214261

Browse files
committed
Update to React Native 0.70.2, patch broken scaleY
1 parent 55052e6 commit 3214261

19 files changed

+1429
-1918
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ build/
3232
local.properties
3333
*.iml
3434
*.hprof
35+
.cxx/
3536

3637
# Visual Studio Code
3738
#

.node-version

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

android/app/build.gradle

+15-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apply plugin: "com.android.application"
22
apply plugin: "kotlin-android" // manual
33

44
import com.android.build.OutputFile
5+
import org.apache.tools.ant.taskdefs.condition.Os
56

67
/**
78
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -143,22 +144,14 @@ android {
143144
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144145

145146
if (isNewArchitectureEnabled()) {
146-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
147+
// We configure the CMake build only if you decide to opt-in for the New Architecture.
147148
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 "enderchat_appmodules"
149+
cmake {
150+
arguments "-DPROJECT_BUILD_DIR=$buildDir",
151+
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
152+
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
153+
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
154+
"-DANDROID_STL=c++_shared"
162155
}
163156
}
164157
if (!enableSeparateBuildPerCPUArchitecture) {
@@ -172,8 +165,8 @@ android {
172165
if (isNewArchitectureEnabled()) {
173166
// We configure the NDK build only if you decide to opt-in for the New Architecture.
174167
externalNativeBuild {
175-
ndkBuild {
176-
path "$projectDir/src/main/jni/Android.mk"
168+
cmake {
169+
path "$projectDir/src/main/jni/CMakeLists.txt"
177170
}
178171
}
179172
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
@@ -195,15 +188,15 @@ android {
195188
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
196189

197190
// Due to a bug inside AGP, we have to explicitly set a dependency
198-
// between configureNdkBuild* tasks and the preBuild tasks.
191+
// between configureCMakeDebug* tasks and the preBuild tasks.
199192
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
200-
configureNdkBuildRelease.dependsOn(preReleaseBuild)
201-
configureNdkBuildDebug.dependsOn(preDebugBuild)
193+
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
194+
configureCMakeDebug.dependsOn(preDebugBuild)
202195
reactNativeArchitectures().each { architecture ->
203-
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
196+
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
204197
dependsOn("preDebugBuild")
205198
}
206-
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
199+
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
207200
dependsOn("preReleaseBuild")
208201
}
209202
}

android/app/src/main/jni/Android.mk

-48
This file was deleted.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
# Define the library name here.
4+
project(enderchat_appmodules)
5+
6+
# This file includes all the necessary to let you build your application with the New Architecture.
7+
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)

android/app/src/main/jni/MainApplicationModuleProvider.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "MainApplicationModuleProvider.h"
22

3+
#include <rncli.h>
34
#include <rncore.h>
45

56
namespace facebook {
67
namespace react {
78

89
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
9-
const std::string moduleName,
10+
const std::string &moduleName,
1011
const JavaTurboModule::InitParams &params) {
1112
// Here you can provide your own module provider for TurboModules coming from
1213
// either your application or from external libraries. The approach to follow
@@ -17,6 +18,13 @@ std::shared_ptr<TurboModule> MainApplicationModuleProvider(
1718
// return module;
1819
// }
1920
// return rncore_ModuleProvider(moduleName, params);
21+
22+
// Module providers autolinked by RN CLI
23+
auto rncli_module = rncli_ModuleProvider(moduleName, params);
24+
if (rncli_module != nullptr) {
25+
return rncli_module;
26+
}
27+
2028
return rncore_ModuleProvider(moduleName, params);
2129
}
2230

android/app/src/main/jni/MainApplicationModuleProvider.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace facebook {
99
namespace react {
1010

1111
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
12-
const std::string moduleName,
12+
const std::string &moduleName,
1313
const JavaTurboModule::InitParams &params);
1414

1515
} // namespace react

android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ void MainApplicationTurboModuleManagerDelegate::registerNatives() {
2222

2323
std::shared_ptr<TurboModule>
2424
MainApplicationTurboModuleManagerDelegate::getTurboModule(
25-
const std::string name,
26-
const std::shared_ptr<CallInvoker> jsInvoker) {
25+
const std::string &name,
26+
const std::shared_ptr<CallInvoker> &jsInvoker) {
2727
// Not implemented yet: provide pure-C++ NativeModules here.
2828
return nullptr;
2929
}
3030

3131
std::shared_ptr<TurboModule>
3232
MainApplicationTurboModuleManagerDelegate::getTurboModule(
33-
const std::string name,
33+
const std::string &name,
3434
const JavaTurboModule::InitParams &params) {
3535
return MainApplicationModuleProvider(name, params);
3636
}
3737

3838
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
39-
std::string name) {
39+
const std::string &name) {
4040
return getTurboModule(name, nullptr) != nullptr ||
4141
getTurboModule(name, {.moduleName = name}) != nullptr;
4242
}

android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ class MainApplicationTurboModuleManagerDelegate
2121
static void registerNatives();
2222

2323
std::shared_ptr<TurboModule> getTurboModule(
24-
const std::string name,
25-
const std::shared_ptr<CallInvoker> jsInvoker) override;
24+
const std::string &name,
25+
const std::shared_ptr<CallInvoker> &jsInvoker) override;
2626
std::shared_ptr<TurboModule> getTurboModule(
27-
const std::string name,
27+
const std::string &name,
2828
const JavaTurboModule::InitParams &params) override;
2929

3030
/**
3131
* Test-only method. Allows user to verify whether a TurboModule can be
3232
* created by instances of this class.
3333
*/
34-
bool canCreateTurboModule(std::string name);
34+
bool canCreateTurboModule(const std::string &name);
3535
};
3636

3737
} // namespace react

android/app/src/main/jni/MainComponentsRegistry.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <fbjni/fbjni.h>
55
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
66
#include <react/renderer/components/rncore/ComponentDescriptors.h>
7+
#include <rncli.h>
78

89
namespace facebook {
910
namespace react {
@@ -14,6 +15,9 @@ std::shared_ptr<ComponentDescriptorProviderRegistry const>
1415
MainComponentsRegistry::sharedProviderRegistry() {
1516
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
1617

18+
// Autolinked providers registered by RN CLI
19+
rncli_registerProviders(providerRegistry);
20+
1721
// Custom Fabric Components go here. You can register custom
1822
// components coming from your App or from 3rd party libraries here.
1923
//

android/build.gradle

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.apache.tools.ant.taskdefs.condition.Os
2-
31
// Top-level build file where you can add configuration options common to all sub-projects/modules.
42

53
buildscript {
@@ -23,7 +21,7 @@ buildscript {
2321
mavenCentral()
2422
}
2523
dependencies {
26-
classpath("com.android.tools.build:gradle:7.1.1")
24+
classpath("com.android.tools.build:gradle:7.2.1")
2725
classpath("com.facebook.react:react-native-gradle-plugin")
2826
classpath("de.undercouch:gradle-download-task:5.0.1")
2927
// NOTE: Do not place your application dependencies here; they belong
285 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

index.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { AppRegistry } from 'react-native'
88
import App from './src/App'
99
import { name as appName } from './app.json'
1010

11+
// Add scaleY back to work around its removal in React Native 0.70.
12+
import ViewReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes'
13+
ViewReactNativeStyleAttributes.scaleY = true
14+
1115
global.Buffer = require('buffer').Buffer
1216
// global.process = require('process');
1317
global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production'

ios/EnderChat.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@
570570
COPY_PHASE_STRIP = NO;
571571
ENABLE_STRICT_OBJC_MSGSEND = YES;
572572
ENABLE_TESTABILITY = YES;
573-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
573+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
574574
GCC_C_LANGUAGE_STANDARD = gnu99;
575575
GCC_DYNAMIC_NO_PIC = NO;
576576
GCC_NO_COMMON_BLOCKS = YES;
@@ -642,7 +642,7 @@
642642
COPY_PHASE_STRIP = YES;
643643
ENABLE_NS_ASSERTIONS = NO;
644644
ENABLE_STRICT_OBJC_MSGSEND = YES;
645-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
645+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386 ;
646646
GCC_C_LANGUAGE_STANDARD = gnu99;
647647
GCC_NO_COMMON_BLOCKS = YES;
648648
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

ios/Podfile

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
44
platform :ios, '12.4'
55
install! 'cocoapods', :deterministic_uuids => false
66

7-
production = ENV["PRODUCTION"] == "1"
8-
97
target 'EnderChat' do
108
config = use_native_modules!
119

@@ -14,10 +12,15 @@ target 'EnderChat' do
1412

1513
use_react_native!(
1614
:path => config[:reactNativePath],
17-
# to enable hermes on iOS, change `false` to `true` and then install pods
18-
:production => production,
19-
:hermes_enabled => flags[:hermes_enabled],
15+
# Hermes is now enabled by default. Disable by setting this flag to false.
16+
# Upcoming versions of React Native may rely on get_default_flags(), but
17+
# we make it explicit here to aid in the React Native upgrade process.
18+
:hermes_enabled => true,
2019
:fabric_enabled => flags[:fabric_enabled],
20+
# Enables Flipper.
21+
#
22+
# Note that if you have use_frameworks! enabled, Flipper will not work and
23+
# you should disable the next line.
2124
:flipper_configuration => FlipperConfiguration.enabled,
2225
# An absolute path to your application root.
2326
:app_path => "#{Pod::Config.instance.installation_root}/.."
@@ -29,7 +32,12 @@ target 'EnderChat' do
2932
end
3033

3134
post_install do |installer|
32-
react_native_post_install(installer)
35+
react_native_post_install(
36+
installer,
37+
# Set `mac_catalyst_enabled` to `true` in order to apply patches
38+
# necessary for Mac Catalyst builds
39+
:mac_catalyst_enabled => false
40+
)
3341
__apply_Xcode_12_5_M1_post_install_workaround(installer)
3442
end
3543
end

0 commit comments

Comments
 (0)