Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Upgrade sample and E2E tests to RN 0.75 #4155

Merged
merged 27 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4a409cb
Updates RN to 0.75.4 in the sample app and E2E test
antonis Oct 7, 2024
3ff1e71
Removes Flipper from iOS
antonis Oct 7, 2024
a5ef6c8
Revert changes in the test apps for now
antonis Oct 8, 2024
a67410e
Update e2e tests dependencies
antonis Oct 8, 2024
03608cf
Updates Android sample
antonis Oct 8, 2024
44e1e0b
Updates iOS sample
antonis Oct 8, 2024
dddcaad
Merge branch 'v6' into antonis/rn-0.75.4-no-flipper
antonis Oct 8, 2024
4acda45
Updates lockfile
antonis Oct 8, 2024
2c6e9e6
Updates changelog
antonis Oct 8, 2024
2a51888
Adds codegen missing targetPlatform parameter
antonis Oct 8, 2024
86990ed
Fixes lint issue (see https://github.com/facebook/react-native/issues…
antonis Oct 8, 2024
d0a8a29
enable corepack in testflight dependencies step
antonis Oct 9, 2024
ce4ed26
Sets the newArchEnabled=false for legacy builds
antonis Oct 9, 2024
9c3480c
enable corepack in testflight build step
antonis Oct 9, 2024
21228bd
Enable corepack in a separate step
antonis Oct 9, 2024
47d108d
Removes corepack step
antonis Oct 9, 2024
1ca6390
Updates OnLoad.cpp and CMakeList.txt to match the RN version samples
antonis Oct 9, 2024
83169cc
Enable corepack and remove cache check
antonis Oct 9, 2024
9b6f84e
Remove changelog
antonis Oct 11, 2024
3b165dc
Reverts CMakeLists.txt change
antonis Oct 11, 2024
e5a1bb2
Reverts code removal
antonis Oct 11, 2024
9497914
Update yarn cache in testflight build
antonis Oct 14, 2024
c45761a
Updates PrivacyInfo
antonis Oct 14, 2024
9a717b3
Merge branch 'v6' into antonis/rn-0.75.4-no-flipper
antonis Oct 14, 2024
f4105bd
misc(ci): Remove unused testflight node_modules cache (#4178)
krystofwoldrich Oct 15, 2024
49408ec
Merge branch 'main' into antonis/rn-0.75.4-no-flipper
antonis Oct 15, 2024
31054a9
Merge branch 'main' into antonis/rn-0.75.4-no-flipper
antonis Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
cd samples/react-native/ios
node ../node_modules/react-native/scripts/generate-codegen-artifacts.js \
--path .. \
--outputPath codegen
--outputPath codegen \
--targetPlatform ios
steps:
- uses: actions/checkout@v4
- run: corepack enable
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ jobs:
strategy:
fail-fast: false # keeps matrix running if one fails
matrix:
rn-version: ['0.65.3', '0.73.9']
rn-version: ['0.65.3', '0.75.4']
rn-architecture: ['legacy', 'new']
platform: ['android', 'ios']
build-type: ['production']
ios-use-frameworks: ['no', 'static', 'dynamic']
engine: ['hermes', 'jsc']
include:
- platform: ios
rn-version: '0.73.9'
rn-version: '0.75.4'
runs-on: macos-14 # uses m1 https://github.blog/changelog/2024-01-30-github-actions-macos-14-sonoma-is-now-available/
runtime: 'latest'
device: 'iPhone 14'
Expand All @@ -185,7 +185,7 @@ jobs:
runs-on: ubuntu-latest
exclude:
# exclude JSC for new RN versions (keeping the matrix manageable)
- rn-version: '0.73.9'
- rn-version: '0.75.4'
engine: 'jsc'
# exclude all rn versions lower than 0.70.0 for new architecture
- rn-version: '0.65.3'
Expand Down Expand Up @@ -304,15 +304,15 @@ jobs:
strategy:
fail-fast: false # keeps matrix running if one fails
matrix:
rn-version: ['0.65.3', '0.73.9']
rn-version: ['0.65.3', '0.75.4']
rn-architecture: ['legacy', 'new']
platform: ['android', 'ios']
build-type: ['production']
ios-use-frameworks: ['no'] # test only no framworks
engine: ['hermes', 'jsc']
include:
- platform: ios
rn-version: '0.73.9'
rn-version: '0.75.4'
runs-on: macos-14 # uses m1 https://github.blog/changelog/2024-01-30-github-actions-macos-14-sonoma-is-now-available/
runtime: 'latest'
device: 'iPhone 14'
Expand All @@ -330,10 +330,10 @@ jobs:
# e2e test only the default combinations
- rn-version: '0.65.3'
engine: 'hermes'
- rn-version: '0.73.9'
- rn-version: '0.75.4'
engine: 'jsc'
# E2E timeout due to a race condition https://github.com/facebook/react-native/issues/42123#issuecomment-1881203719
- rn-version: '0.73.9'
- rn-version: '0.75.4'
platform: 'ios'
rn-architecture: 'new'
env:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ jobs:
[[ "${{ matrix.platform }}" == "ios" ]] && cd react-native/ios
[[ "${{ matrix.platform }}" == "macos" ]] && cd react-native-macos/macos

export NO_FLIPPER=1 # Flipper is causing build issues on iOS, so we disable it
[[ "${{ matrix.build-type }}" == "production" ]] && ENABLE_PROD=1 || ENABLE_PROD=0
[[ "${{ matrix.rn-architecture }}" == "new" ]] && ENABLE_NEW_ARCH=1 || ENABLE_NEW_ARCH=0
[[ "${{ matrix.ios-use-frameworks }}" == "dynamic-frameworks" ]] && export USE_FRAMEWORKS=dynamic
Expand All @@ -119,6 +118,11 @@ jobs:
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
echo 'New Architecture enabled'
elif [[ ${{ matrix.rn-architecture }} == 'legacy' ]]; then
antonis marked this conversation as resolved.
Show resolved Hide resolved
perl -i -pe's/newArchEnabled=true/newArchEnabled=false/g' gradle.properties
echo 'Legacy Architecture enabled'
else
echo 'No changes for architecture: ${{ matrix.rn-architecture }}'
fi
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ jobs:
ruby-version: '3.3.0' # based on what is used in the sample
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 1 # cache the installed gems
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18
antonis marked this conversation as resolved.
Show resolved Hide resolved
cache: 'yarn'
cache-dependency-path: yarn.lock
- uses: actions/cache@v4
id: deps-cache
with:
Expand All @@ -37,7 +40,6 @@ jobs:
samples/react-native/node_modules
key: ${{ github.workflow }}-${{ github.job }}-${{ hashFiles('yarn.lock', 'samples/react-native/yarn.lock') }}
- name: Install Dependencies
if: steps.deps-cache.outputs['cache-hit'] != 'true'
run: |
yarn install
cd samples/react-native && yarn install
Expand All @@ -52,7 +54,7 @@ jobs:

- name: Pod Install
working-directory: samples/react-native/ios
run: NO_FLIPPER=1 PRODUCTION=1 bundle exec pod install
run: PRODUCTION=1 bundle exec pod install

- name: Run Fastlane
working-directory: samples/react-native
Expand Down
5 changes: 0 additions & 5 deletions dev-packages/e2e-tests/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ if (!env.USE_FRAMEWORKS || env.USE_FRAMEWORKS === 'no') {
delete env.USE_FRAMEWORKS;
}

if (platform == 'ios') {
// Flipper is causing build issues on iOS, so we disable it
env.NO_FLIPPER = 1;
}

const e2eDir = path.resolve(__dirname);
const e2eTestPackageName = JSON.parse(fs.readFileSync(`${e2eDir}/package.json`, 'utf8')).name;
const patchScriptsDir = path.resolve(e2eDir, 'patch-scripts');
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"appium-xcuitest-driver": "5.13.0",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"react": "18.2.0",
"react-native": "0.73.9",
"react": "18.3.1",
"react-native": "0.75.4",
"typescript": "4.9.5",
"webdriverio": "^8.27.0"
},
Expand Down
2 changes: 1 addition & 1 deletion samples/react-native/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ yarn-error.log
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
Expand Down
6 changes: 3 additions & 3 deletions samples/react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -196,7 +199,6 @@ android {
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand All @@ -205,8 +207,6 @@ dependencies {
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

if (newArchEnabled.toBoolean()) {
android {
externalNativeBuild {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.flipper.ReactNativeFlipper
import com.facebook.soloader.SoLoader
import io.sentry.Hint
import io.sentry.SentryEvent
Expand All @@ -34,7 +33,7 @@ class MainApplication() : Application(), ReactApplication {
}

override val reactHost: ReactHost
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
get() = getDefaultReactHost(applicationContext, reactNativeHost)

override fun onCreate() {
super.onCreate()
Expand All @@ -46,7 +45,6 @@ class MainApplication() : Application(), ReactApplication {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
}

private fun initializeSentry() {
Expand Down
79 changes: 52 additions & 27 deletions samples/react-native/android/app/src/main/jni/OnLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,66 +27,91 @@
// }
// }

#include <AppSpecs.h>
#include <DefaultComponentsRegistry.h>
#include <DefaultTurboModuleManagerDelegate.h>
#include <autolinking.h>
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <rncli.h>
#include <NativeSampleModule.h>
#include <rncore.h>

namespace facebook {
namespace react {
#ifdef REACT_NATIVE_APP_CODEGEN_HEADER
#include REACT_NATIVE_APP_CODEGEN_HEADER
#endif
#ifdef REACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER
#include REACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER
#endif

namespace facebook::react {

void registerComponents(
std::shared_ptr<ComponentDescriptorProviderRegistry const> registry) {
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
// Custom Fabric Components go here. You can register custom
// components coming from your App or from 3rd party libraries here.
//
// providerRegistry->add(concreteComponentDescriptorProvider<
// AocViewerComponentDescriptor>());
// MyComponentDescriptor>());

// We link app local components if available
#ifdef REACT_NATIVE_APP_COMPONENT_REGISTRATION
REACT_NATIVE_APP_COMPONENT_REGISTRATION(registry);
#endif

// By default we just use the components autolinked by RN CLI
rncli_registerProviders(registry);
// And we fallback to the components autolinked
autolinking_registerProviders(registry);
}

std::shared_ptr<TurboModule> cxxModuleProvider(
const std::string &name,
const std::shared_ptr<CallInvoker> &jsInvoker) {
// Not implemented yet: provide pure-C++ NativeModules here.
if (name == "NativeSampleModule")
{
return std::make_shared<facebook::react::NativeSampleModule>(jsInvoker);
}
return nullptr;
const std::string& name,
const std::shared_ptr<CallInvoker>& jsInvoker) {
// Here you can provide your CXX Turbo Modules coming from
// either your application or from external libraries. The approach to follow
// is similar to the following (for a module called `NativeCxxModuleExample`):
//
// if (name == NativeCxxModuleExample::kModuleName) {
// return std::make_shared<NativeCxxModuleExample>(jsInvoker);
// }

// And we fallback to the CXX module providers autolinked
return autolinking_cxxModuleProvider(name, jsInvoker);
}

std::shared_ptr<TurboModule> javaModuleProvider(
const std::string &name,
const JavaTurboModule::InitParams &params) {
const std::string& name,
const JavaTurboModule::InitParams& params) {
// Here you can provide your own module provider for TurboModules coming from
// either your application or from external libraries. The approach to follow
// is similar to the following (for a library called `samplelibrary`):
//
// auto module = samplelibrary_ModuleProvider(moduleName, params);
// auto module = samplelibrary_ModuleProvider(name, params);
// if (module != nullptr) {
// return module;
// }
// return rncore_ModuleProvider(moduleName, params);
// return rncore_ModuleProvider(name, params);

auto module = AppSpecs_ModuleProvider(name, params);
// We link app local modules if available
#ifdef REACT_NATIVE_APP_MODULE_PROVIDER
auto module = REACT_NATIVE_APP_MODULE_PROVIDER(name, params);
if (module != nullptr) {
return module;
}
#endif

// By default we just use the module providers autolinked by RN CLI
return rncli_ModuleProvider(name, params);
// We first try to look up core modules
if (auto module = rncore_ModuleProvider(name, params)) {
return module;
}

// And we fallback to the module providers autolinked
if (auto module = autolinking_ModuleProvider(name, params)) {
return module;
}

return nullptr;
}

} // namespace react
} // namespace facebook
} // namespace facebook::react

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
return facebook::jni::initialize(vm, [] {
facebook::react::DefaultTurboModuleManagerDelegate::cxxModuleProvider =
&facebook::react::cxxModuleProvider;
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions samples/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 21
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.24"
}
repositories {
google()
Expand Down
2 changes: 0 additions & 2 deletions samples/react-native/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ org.gradle.logging.level=lifecycle
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading
Loading