Skip to content

Commit

Permalink
Support RN 73 (#7844)
Browse files Browse the repository at this point in the history
* Make Android build with RN 73

* Updated node version

* Updated java version

* Removed buildkite

* Updated buildtooks

* lock buildtools version

* Fixed tests

* Fixed build report

* Fixed ios build

* try to fix build

* Updated detox to latest version

* Undo detox upgrade

* Added new detox

* fix(RN73 migration): replace obsolete react classes.

* project: remove deprecated `@types/detox` (migrated to `@wix/detox`).

* podspec: add upgrade requirement

* project: remove development team from config.

* fix(RN73,iOS): fix file extension to obj-c++ (.m->.mm)

Renamed file extension to .mm since it’s now importing obj-c++
 code (making it a obj-c++ file).

* fix(iOS): fix Fabric imports in AppDelegate.

* fix(iOS): add missing header path in target config.

* Upgraded target sdk and compile sdk

---------

Co-authored-by: Asaf Korem <[email protected]>
  • Loading branch information
gosha212 and asafkorem authored Feb 18, 2024
1 parent 134e3fb commit 0be34f9
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 136 deletions.
61 changes: 0 additions & 61 deletions .buildkite/pipeline.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
10 changes: 8 additions & 2 deletions ReactNativeNavigation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ Pod::Spec.new do |s|

s.module_name = 'ReactNativeNavigation'
s.default_subspec = 'Core'

s.subspec 'Core' do |ss|
s.source = { :git => "https://github.com/wix/react-native-navigation.git", :tag => "#{s.version}" }
s.source_files = 'lib/ios/**/*.{h,m,mm,cpp}'
s.exclude_files = "lib/ios/ReactNativeNavigationTests/**/*.*", "lib/ios/OCMock/**/*.*"
end

if fabric_enabled
install_modules_dependencies(s)

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
fabric_flags = fabric_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''

s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly" "$(PODS_ROOT)/Headers/Private/React-Core"',
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly" "$(PODS_ROOT)/Headers/Private/React-Core" "$(PODS_ROOT)/Headers/Private/Yoga"',
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
}

s.compiler_flags = folly_compiler_flags + ' ' + '-DRCT_NEW_ARCH_ENABLED'
s.requires_arc = true

Expand All @@ -45,6 +50,7 @@ Pod::Spec.new do |s|
s.dependency "React-runtimeexecutor"
s.dependency "React-rncore"
end

s.dependency 'React-Core'
s.dependency 'React-CoreModules'
s.dependency 'React-RCTImage'
Expand Down
24 changes: 12 additions & 12 deletions lib/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ def safeExtGetFallbackLowerBound(prop, fallback) {
Math.max(safeExtGet(prop,fallback),fallback)
}

def DEFAULT_COMPILE_SDK_VERSION = 33
def DEFAULT_COMPILE_SDK_VERSION = 34
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 33
def DEFAULT_TARGET_SDK_VERSION = 34
def DEFAULT_KOTLIN_VERSION = "1.5.31"
def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
def kotlinVersion = safeExtGet("RNNKotlinVersion", DEFAULT_KOTLIN_VERSION)
def kotlinStdlib = safeExtGet('RNNKotlinStdlib',DEFAULT_KOTLIN_STDLIB )
def kotlinCoroutinesCore = safeExtGet('RNNKotlinCoroutinesCore', '1.5.2')
android {
compileSdkVersion safeExtGetFallbackLowerBound('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion = "33.0.0"
buildToolsVersion = "34.0.0"
defaultConfig {
minSdkVersion safeExtGetFallbackLowerBound('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGetFallbackLowerBound('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
Expand Down Expand Up @@ -56,17 +56,17 @@ android {
def repeatLength = output.length()
println '\n\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength) + '\n'

println "see report at file://${t.reports.html.destination}/index.html"
println "see report at file://${t.reports.html.outputLocation}/index.html"
}
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
jvmTarget = JavaVersion.VERSION_17
}

flavorDimensions "RNN.reactNativeVersion"
Expand Down Expand Up @@ -172,14 +172,14 @@ List reactNativeVersionComponents(rnPackageJsonFile) {

dependencies {

implementation "androidx.core:core-ktx:1.6.0"
implementation "androidx.core:core-ktx:1.6.1"
implementation "org.jetbrains.kotlin:$kotlinStdlib:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesCore"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.google.android.material:material:1.2.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.annotation:annotation:1.7.1'
implementation 'com.google.android.material:material:1.11.0'

implementation 'com.github.wix-playground:ahbottomnavigation:3.3.0'
// implementation project(':AHBottomNavigation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ open class ButtonPresenter(private val context: Context, private val button: But

class WixAccessibilityDelegateCompat: AccessibilityDelegateCompat(){
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfoCompat?
host: View,
info: AccessibilityNodeInfoCompat
) {
super.onInitializeAccessibilityNodeInfo(host, info)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import static org.assertj.core.api.Java6Assertions.*;

import com.reactnativenavigation.R;

public class EnvironmentTest extends BaseTest {
@Test
public void assertJ() {
Expand All @@ -33,7 +35,7 @@ public void supportDesign() {

@Test
public void androidR() {
assertThat(R.string.bottom_sheet_behavior).isNotZero();
assertThat(com.google.android.material.R.string.bottom_sheet_behavior).isNotZero();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Collections;
import java.util.List;


public class TestApplication extends Application implements ReactApplication {
private final ReactNativeHost host = new ReactNativeHost(this) {
@Override
Expand All @@ -25,7 +26,7 @@ protected List<ReactPackage> getPackages() {
@Override
public void onCreate() {
super.onCreate();
setTheme(R.style.Theme_AppCompat);
setTheme(androidx.appcompat.R.style.Theme_AppCompat);
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions lib/ios/RNNAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
#import "RCTLegacyInteropComponents.h"
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTLegacyViewManagerInteropComponentView.h>
#import <React/RCTRuntimeExecutorFromBridge.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterStub.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
Expand Down
4 changes: 2 additions & 2 deletions lib/ios/RNNReactView.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfaceHostingProxyRootView.h>
#else
#import <React/RCTRootView.h>
#endif
Expand Down Expand Up @@ -32,7 +32,7 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);

#ifdef RCT_NEW_ARCH_ENABLED
@interface RNNReactView
: RCTFabricSurfaceHostingProxyRootView <RCTRootViewDelegate, RNNComponentProtocol>
: RCTSurfaceHostingProxyRootView <RCTRootViewDelegate, RNNComponentProtocol>
#else
@interface RNNReactView : RCTRootView <RCTRootViewDelegate, RNNComponentProtocol>
#endif
Expand Down
10 changes: 6 additions & 4 deletions lib/ios/RNNReactView.m → lib/ios/RNNReactView.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "RNNReactView.h"
#import <React/RCTRootContentView.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTFabricSurface.h>
#endif

@implementation RNNReactView {
BOOL _isAppeared;
}
Expand All @@ -11,10 +15,8 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
eventEmitter:(RNNEventEmitter *)eventEmitter
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
self = [super initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties
sizeMeasureMode:sizeMeasureMode];
RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
self = [super initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
#else
- (instancetype)initWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
Expand Down
4 changes: 4 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const path = require('node:path');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const config = {
projectRoot: `${__dirname}`,
resolver: {
enableGlobalPackages: true,
},
watchFolders: [__dirname],
};

Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@
"@babel/plugin-proposal-export-namespace-from": "7.10.1",
"@babel/runtime": "7.22.6",
"@babel/types": "7.22.5",
"@react-native/metro-config": "^0.73.0",
"@babel/preset-env": "^7.22.9",
"@react-native/metro-config": "^0.73.2",
"@react-native/babel-preset": "^0.73.18",
"@react-native/typescript-config": "^0.73.1",
"@react-native-community/blur": "^3.6.0",
"@react-native-community/datetimepicker": "^3.4.7",
"@react-native-community/eslint-config": "2.0.0",
"@react-native-community/netinfo": "^5.9.4",
"@testing-library/jest-native": "^5.4.2",
"@testing-library/react-native": "^12.0.1",
"@types/detox": "17.14.3",
"@types/hoist-non-react-statics": "^3.0.1",
"@types/jasmine": "3.5.10",
"@types/jest": "27.0.2",
Expand All @@ -96,7 +98,7 @@
"@typescript-eslint/parser": "4.33.0",
"babel-jest": "^27.0.0",
"clang-format": "^1.4.0",
"detox": "20.9.0",
"detox": "20.18.1",
"detox-testing-library-rnn-adapter": "^2.0.3",
"eslint": "7.32.0",
"eslint-config-prettier": "6.11.0",
Expand All @@ -111,10 +113,10 @@
"pngjs": "^6.0.0",
"prettier": "2.1.2",
"react": "18.2.0",
"react-native": "0.72.3",
"react-native": "0.73.3",
"react-native-fast-image": "^8.6.3",
"react-native-gesture-handler": "^2.10.1",
"react-native-reanimated": "3.4.1",
"react-native-reanimated": "3.6.2",
"react-native-ui-lib": "7.3.6",
"react-redux": "5.x.x",
"react-test-renderer": "18.2.0",
Expand Down
6 changes: 4 additions & 2 deletions playground/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ def jscFlavor = 'org.webkit:android-jsc:+'
android {
compileSdkVersion rootProject.ext.get("compileSdkVersion")

namespace "com.reactnativenavigation.playground"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import com.reactnativenavigation.R;

public class FragmentComponent implements ExternalComponent {
private final FrameLayout content;
Expand Down
18 changes: 14 additions & 4 deletions playground/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

buildscript {
ext {
kotlinVersion = "1.7.10"
kotlinVersion = "1.8.10"
RNNKotlinVersion = kotlinVersion
detoxKotlinVersion = kotlinVersion
compileSdkVersion = 33
buildToolsVersion = "33.0.0"
compileSdkVersion = 34
buildToolsVersion = "34.0.0"
minSdkVersion = 21
targetSdkVersion = 33
targetSdkVersion = 34
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
Expand Down Expand Up @@ -36,3 +36,13 @@ allprojects {
}
}
}

subprojects {
afterEvaluate { p ->
if (p.hasProperty('android')) {
android {
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jul 28 13:48:47 IDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading

0 comments on commit 0be34f9

Please sign in to comment.