Skip to content

Commit e65ebc9

Browse files
authored
fix: fix build error when use RN >= 0.76 (#24)
* fix: fix build error when use RN >= 0.76 * ci: use Node 18 * fix: correct Node version to use * fix: correct type define path * chore: add build ignore paths * ci: copy native test workflow from newer projects * ci: filter trigger * chore: add turbo * fix: fix package manager * chore: update yarn.lock * chore: use yarn workspace to manage project * chore: correct command * chore: update yarn.lock * fix: fix turbo config * chore: change `react-native-builder-bob` version
1 parent 4043f28 commit e65ebc9

Some content is hidden

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

54 files changed

+14461
-15967
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runs:
55
using: composite
66
steps:
77
- name: Setup Node.js
8-
uses: actions/setup-node@v3
8+
uses: actions/setup-node@v4
99
with:
1010
node-version-file: .nvmrc
1111

.github/workflows/native.yml

Lines changed: 100 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,130 @@
11
name: Native CI
22
on:
33
push:
4+
branches:
5+
- main
46
paths:
57
- 'ios/**'
68
- 'android/**'
79
- 'cpp/**'
810
- 'example/ios/**'
911
- 'example/android/**'
1012
- '.github/workflows/native.yml'
13+
pull_request:
14+
branches:
15+
- main
16+
merge_group:
17+
types:
18+
- checks_requested
1119

1220
concurrency:
1321
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1422
cancel-in-progress: true
1523

1624
jobs:
17-
test-ios:
18-
runs-on: macOS-latest
25+
build-android:
26+
runs-on: ubuntu-latest
27+
env:
28+
TURBO_CACHE_DIR: .turbo/android
1929
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/setup-node@v3.6.0
22-
with:
23-
node-version: 16.x
24-
- name: Setup ccache
25-
uses: hendrikmuhs/ccache-action@v1.2
26-
- name: Get yarn cache directory path
27-
id: yarn-cache-dir-path
28-
run: echo "::set-output name=dir::$(yarn cache dir)"
29-
- uses: actions/cache@v3
30-
id: yarn-cache
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
33+
- name: Setup
34+
uses: ./.github/actions/setup
35+
36+
- name: Cache turborepo for Android
37+
uses: actions/cache@v3
3138
with:
32-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
33-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
39+
path: ${{ env.TURBO_CACHE_DIR }}
40+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
3441
restore-keys: |
35-
${{ runner.os }}-yarn-
36-
- name: Cache pods
42+
${{ runner.os }}-turborepo-android-
43+
44+
- name: Check turborepo cache for Android
45+
run: |
46+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
47+
48+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
49+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
50+
fi
51+
52+
- name: Install JDK
53+
if: env.turbo_cache_hit != 1
54+
uses: actions/setup-java@v3
55+
with:
56+
distribution: 'zulu'
57+
java-version: '17'
58+
59+
- name: Finalize Android SDK
60+
if: env.turbo_cache_hit != 1
61+
run: |
62+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
63+
64+
- name: Cache Gradle
65+
if: env.turbo_cache_hit != 1
3766
uses: actions/cache@v3
3867
with:
3968
path: |
40-
example/ios/Pods
41-
example/ios/build
42-
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
69+
~/.gradle/wrapper
70+
~/.gradle/caches
71+
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
4372
restore-keys: |
44-
${{ runner.os }}-pods-
45-
- name: Build example
73+
${{ runner.os }}-gradle-
74+
75+
- name: Build example for Android
76+
env:
77+
JAVA_OPTS: "-XX:MaxHeapSize=6g"
4678
run: |
47-
yarn
48-
xcodebuild -workspace example/ios/JsiUdpExample.xcworkspace -scheme JsiUdpExample -configuration Debug -sdk iphonesimulator -derivedDataPath example/ios/build
49-
test-android:
50-
runs-on: macOS-latest
79+
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
80+
81+
build-ios:
82+
runs-on: macos-14
83+
env:
84+
TURBO_CACHE_DIR: .turbo/ios
85+
ENABLE_TSC_USB: '1'
5186
steps:
52-
- uses: actions/checkout@v3
53-
- uses: actions/setup-node@v3.6.0
54-
with:
55-
node-version: 16.x
56-
- name: Setup ccache
57-
uses: hendrikmuhs/ccache-action@v1.2
58-
- name: Get yarn cache directory path
59-
id: yarn-cache-dir-path
60-
run: echo "::set-output name=dir::$(yarn cache dir)"
61-
- uses: actions/cache@v3
62-
id: yarn-cache
87+
- name: Checkout
88+
uses: actions/checkout@v3
89+
90+
- name: Setup
91+
uses: ./.github/actions/setup
92+
93+
- name: Cache turborepo for iOS
94+
uses: actions/cache@v3
6395
with:
64-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
65-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
96+
path: ${{ env.TURBO_CACHE_DIR }}
97+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
6698
restore-keys: |
67-
${{ runner.os }}-yarn-
68-
- name: Install Java
69-
uses: actions/setup-java@v3
99+
${{ runner.os }}-turborepo-ios-
100+
101+
- name: Check turborepo cache for iOS
102+
run: |
103+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
104+
105+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
106+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
107+
fi
108+
109+
- name: Cache cocoapods
110+
if: env.turbo_cache_hit != 1
111+
id: cocoapods-cache
112+
uses: actions/cache@v3
70113
with:
71-
distribution: zulu
72-
java-version: 17
73-
- name: Build example
114+
path: |
115+
**/ios/Pods
116+
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
117+
restore-keys: |
118+
${{ runner.os }}-cocoapods-
119+
120+
- name: Install cocoapods
121+
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
122+
run: |
123+
cd example/ios
124+
pod install
74125
env:
75-
NDK_CCACHE: ccache
126+
NO_FLIPPER: 1
127+
128+
- name: Build example for iOS
76129
run: |
77-
yarn
78-
cd example/android
79-
./gradlew assembleDebug
130+
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ project.xcworkspace
3939
.settings
4040
local.properties
4141
android.iml
42+
.kotlin
4243

4344
# Cocoapods
4445
#
@@ -68,3 +69,15 @@ android/keystores/debug.keystore
6869

6970
# generated by bob
7071
lib/
72+
73+
# Yarn
74+
.yarn/*
75+
!.yarn/patches
76+
!.yarn/plugins
77+
!.yarn/releases
78+
!.yarn/sdks
79+
!.yarn/versions
80+
81+
# React Native Codegen
82+
ios/generated
83+
android/generated

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.18.1
1+
v18

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 541 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-3.6.1.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
nodeLinker: node-modules
2+
nmHoistingLimits: workspaces
3+
4+
plugins:
5+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
6+
spec: "@yarnpkg/plugin-interactive-tools"
7+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
8+
spec: "@yarnpkg/plugin-workspace-tools"
9+
10+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

android/CMakeLists.txt

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,47 @@ endif()
9191

9292
find_library(LOG_LIB log)
9393

94-
target_include_directories(
95-
jsiudp
96-
PRIVATE
97-
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
98-
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
99-
"${NODE_MODULES_DIR}/react-native/ReactCommon"
100-
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
101-
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
102-
../cpp
103-
${libfbjni_include_DIRS}
104-
)
94+
if (${ReactAndroid_VERSION_MINOR} GREATER_EQUAL 76)
95+
target_include_directories(
96+
jsiudp
97+
PRIVATE
98+
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
99+
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
100+
"${NODE_MODULES_DIR}/react-native/ReactCommon"
101+
../cpp
102+
${libfbjni_include_DIRS}
103+
)
105104

106-
target_link_libraries(
107-
jsiudp
108-
${LOG_LIB}
109-
${FBJNI_LIBRARY}
110-
${REACT_LIB}
111-
${JSI_LIB}
112-
${TURBOMODULES_LIB}
113-
android
114-
)
105+
target_link_libraries(
106+
jsiudp
107+
${LOG_LIB}
108+
ReactAndroid::reactnative
109+
ReactAndroid::jsi
110+
fbjni::fbjni
111+
)
112+
113+
# Exclude libreactnative.so to avoid conflicts
114+
set(CMAKE_EXCLUDE_FILES "libreactnative.so")
115+
else()
116+
target_include_directories(
117+
jsiudp
118+
PRIVATE
119+
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
120+
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
121+
"${NODE_MODULES_DIR}/react-native/ReactCommon"
122+
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
123+
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
124+
../cpp
125+
${libfbjni_include_DIRS}
126+
)
127+
128+
target_link_libraries(
129+
jsiudp
130+
${LOG_LIB}
131+
${FBJNI_LIBRARY}
132+
${REACT_LIB}
133+
${JSI_LIB}
134+
${TURBOMODULES_LIB}
135+
android
136+
)
137+
endif()

0 commit comments

Comments
 (0)