Skip to content

Commit 54d046e

Browse files
committed
[wip] xcframework build script
1 parent 1fd29d5 commit 54d046e

File tree

13 files changed

+1017
-1382
lines changed

13 files changed

+1017
-1382
lines changed

.github/workflows/pr.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
run: npm install
130130
working-directory: ./Apps/BRNPlayground
131131

132-
- name: Build Windows Bundle
132+
- name: Build iOS Bundle
133133
run: npm run build:ios
134134
working-directory: ./Apps/BRNPlayground
135135

@@ -140,6 +140,14 @@ jobs:
140140
run: npx gulp buildIOSRNTA
141141
working-directory: ./Package
142142

143+
- name: Cache XCFrameworks
144+
uses: actions/cache@v2
145+
with:
146+
path: Modules/@babylonjs/react-native-iosandroid/ios/libs
147+
key: ${{ runner.os }}-xcframeworks-${{ github.sha }}
148+
restore-keys: |
149+
${{ runner.os }}-xcframeworks
150+
143151
test-publish-android-ios:
144152
runs-on: macos-latest
145153
steps:

Apps/BRNPlayground/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

Apps/BRNPlayground/ios/Podfile

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ options = {
77
:bridgeless_enabled => false,
88
:fabric_enabled => false,
99
:hermes_enabled => true,
10-
# Fixes linking issue when using CMake > 3.24
11-
:build_setting_overrides => {
12-
'LIBRARY_SEARCH_PATHS' => '$(inherited) "$(PODS_ROOT)/../../../../Modules/@babylonjs/Build/iOS/build/"/**',
13-
}
1410
}
1511

1612
# react-native-permissions

Apps/BRNPlayground/ios/Podfile.lock

+23-4
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,26 @@ PODS:
12381238
- ReactCommon/turbomodule/core
12391239
- Yoga
12401240
- react-native-babylon (0.0.1):
1241-
- React
1241+
- DoubleConversion
1242+
- glog
1243+
- hermes-engine
1244+
- RCT-Folly (= 2024.01.01.00)
1245+
- RCTRequired
1246+
- RCTTypeSafety
1247+
- React-Core
1248+
- React-debug
1249+
- React-Fabric
1250+
- React-featureflags
1251+
- React-graphics
1252+
- React-ImageManager
1253+
- React-NativeModulesApple
1254+
- React-RCTFabric
1255+
- React-rendererdebug
1256+
- React-utils
1257+
- ReactCodegen
1258+
- ReactCommon/turbomodule/bridging
1259+
- ReactCommon/turbomodule/core
1260+
- Yoga
12421261
- react-native-slider (4.5.2):
12431262
- DoubleConversion
12441263
- glog
@@ -1802,7 +1821,7 @@ SPEC CHECKSUMS:
18021821
React-logger: 4072f39df335ca443932e0ccece41fbeb5ca8404
18031822
React-Mapbuffer: 714f2fae68edcabfc332b754e9fbaa8cfc68fdd4
18041823
React-microtasksnativemodule: 4943ad8f99be8ccf5a63329fa7d269816609df9e
1805-
react-native-babylon: d42edb0fcbf1aa406fda5947db408f6459f9b49a
1824+
react-native-babylon: 6234712503667b128f2a21b17d0d6dcc03c51552
18061825
react-native-slider: 97ce0bd921f40de79cead9754546d5e4e7ba44f8
18071826
React-nativeconfig: 4a9543185905fe41014c06776bf126083795aed9
18081827
React-NativeModulesApple: 0506da59fc40d2e1e6e12a233db5e81c46face27
@@ -1835,8 +1854,8 @@ SPEC CHECKSUMS:
18351854
ReactTestApp-Resources: 7db90c026cccdf40cfa495705ad436ccc4d64154
18361855
RNPermissions: 5a2dafe37c8e0a3fa1d6e0783a1490b1b7fd92d6
18371856
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
1838-
Yoga: 1354c027ab07c7736f99a3bef16172d6f1b12b47
1857+
Yoga: 4ef80d96a5534f0e01b3055f17d1e19a9fc61b63
18391858

1840-
PODFILE CHECKSUM: 1f9ff09dc4914f4ff0a83d4d955065ca4d613829
1859+
PODFILE CHECKSUM: c0272fe43d76243a8a0abcc5781bde0430d39023
18411860

18421861
COCOAPODS: 1.15.2

Apps/BRNPlayground/package-lock.json

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Apps/BRNPlayground/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"start": "react-native start",
1515
"test": "jest",
1616
"windows": "react-native run-windows --sln windows/BRNPlayground.sln",
17-
"postinstall": "node ./postinstall.js"
17+
"postinstall": "node ./postinstall.js",
18+
"build-xcframeworks": "cd ../../Package && npm i && npx gulp buildIOSRNTA"
1819
},
1920
"dependencies": {
2021
"@babylonjs/core": ">=5.53.1",

Modules/@babylonjs/react-native-iosandroid/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ DerivedData
2727
*.ipa
2828
*.xcuserstate
2929
project.xcworkspace
30+
ios/libs
3031

3132
# Android/IntelliJ
3233
#
@@ -51,4 +52,4 @@ CMakeCache.txt
5152
cmake_install.cmake
5253
ReactNativeBabylon.xcodeproj
5354
*.tgz
54-
jsi
55+
jsi

Modules/@babylonjs/react-native-iosandroid/react-native-babylon.podspec

+67-39
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ require "json"
22

33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44

5+
# This Podspec is used for local development
6+
57
Pod::Spec.new do |s|
68
s.name = "react-native-babylon"
79
s.version = package["version"]
@@ -17,47 +19,73 @@ Pod::Spec.new do |s|
1719
s.requires_arc = true
1820
s.xcconfig = { 'USER_HEADER_SEARCH_PATHS' => '$(inherited) ${PODS_TARGET_SRCROOT}/shared ${PODS_TARGET_SRCROOT}/../react-native/shared' }
1921

20-
s.libraries = 'astc-encoder',
21-
'etc1',
22-
'etc2',
23-
'nvtt',
24-
'squish',
25-
'pvrtc',
26-
'iqa',
27-
'edtaa3',
28-
'tinyexr',
29-
'BabylonNative',
30-
'bgfx',
31-
'bimg',
32-
'bx',
33-
'Canvas',
34-
'GenericCodeGen',
35-
'glslang',
36-
'glslang-default-resource-limits',
37-
'Graphics',
38-
'jsRuntime',
39-
'OGLCompiler',
40-
'OSDependent',
41-
'MachineIndependent',
42-
'napi',
43-
'NativeCamera',
44-
'NativeCapture',
45-
'NativeEngine',
46-
'NativeInput',
47-
'NativeOptimizations',
48-
'NativeTracing',
49-
'NativeXR',
50-
'SPIRV',
51-
'spirv-cross-core',
52-
'spirv-cross-msl',
53-
'tinyexr',
54-
'UrlLib',
55-
'Window',
56-
'XMLHttpRequest',
57-
'xr'
22+
if ENV['BUILD_BABYLON_FROM_SOURCE'] == 'true' then
23+
s.libraries = 'astc-encoder',
24+
'etc1',
25+
'etc2',
26+
'nvtt',
27+
'squish',
28+
'pvrtc',
29+
'iqa',
30+
'edtaa3',
31+
'tinyexr',
32+
'BabylonNative',
33+
'bgfx',
34+
'bimg',
35+
'bx',
36+
'Canvas',
37+
'GenericCodeGen',
38+
'glslang',
39+
'glslang-default-resource-limits',
40+
'Graphics',
41+
'jsRuntime',
42+
'OGLCompiler',
43+
'OSDependent',
44+
'MachineIndependent',
45+
'napi',
46+
'NativeCamera',
47+
'NativeCapture',
48+
'NativeEngine',
49+
'NativeInput',
50+
'NativeOptimizations',
51+
'NativeTracing',
52+
'NativeXR',
53+
'SPIRV',
54+
'spirv-cross-core',
55+
'spirv-cross-msl',
56+
'tinyexr',
57+
'UrlLib',
58+
'Window',
59+
'XMLHttpRequest',
60+
'xr'
61+
else
62+
s.vendored_frameworks = "ios/libs/*.xcframework"
63+
end
5864

5965
s.frameworks = "MetalKit", "ARKit"
6066

61-
s.dependency "React"
67+
# install_modules_dependencies has been defined in RN 0.70
68+
# This check ensure that the library can work on older versions of RN
69+
if defined?(install_modules_dependencies)
70+
install_modules_dependencies(s)
71+
else
72+
s.dependency "React-Core"
73+
74+
# Don't install the dependencies when we run `pod install` in the old architecture.
75+
if new_arch_enabled then
76+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
77+
s.pod_target_xcconfig = {
78+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
79+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
80+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
81+
}
82+
s.dependency "React-Codegen"
83+
s.dependency "RCT-Folly"
84+
s.dependency "RCTRequired"
85+
s.dependency "RCTTypeSafety"
86+
s.dependency "ReactCommon/turbomodule/core"
87+
s.dependency "React-RCTFabric"
88+
end
89+
end
6290
end
6391

Modules/@babylonjs/react-native/NativeEngineHook.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function useAppState(): string {
4141

4242
return () => {
4343
if (!!removeListener) {
44-
removeListener();
4544
} else {
45+
// @ts-ignore removeEventListener is available on older RN versions
4646
AppState.removeEventListener("change", onAppStateChanged);
4747
}
4848
};

0 commit comments

Comments
 (0)