From 86ff582d4aec60663155b7ffc5bf9e4e648a063f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 13 Sep 2025 20:47:05 +0200 Subject: [PATCH 1/5] Add matrix with prebuilds for RN core and deps enabled --- .github/workflows/check.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 52aa06c7..b0ef321e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -76,8 +76,16 @@ jobs: - run: npm test test-ios: if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Apple 🍎') - name: Test app (iOS) + name: Test app (iOS${{ matrix.rn-deps-prebuilds && ' / RN deps prebuilds' || '' }}${{ matrix.rn-core-prebuilds && ' / RN core prebuilds' || '' }}) runs-on: macos-latest + strategy: + matrix: + rn-deps-prebuilds: + - true + - false + rn-core-prebuilds: + - true + - false steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -100,6 +108,11 @@ jobs: FERRIC_TARGETS: aarch64-apple-ios-sim - run: npm run pod-install working-directory: apps/test-app + env: + # Optionally enable experimental prebuilds + # https://reactnative.dev/blog/2025/08/12/react-native-0.81#experimental-precompiled-ios-builds + RCT_USE_PREBUILT_RNCORE: ${{ matrix.rn-core-prebuilds && '1' || '0' }} + RCT_USE_RN_DEP: ${{ matrix.rn-deps-prebuilds && '1' || '0' }} - name: Run tests (iOS) run: npm run test:ios:allTests # TODO: Enable release mode when it works From e6f4a7b7a5bb1e42fbec37a30eff8cbf107207c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 14 Sep 2025 19:35:42 +0200 Subject: [PATCH 2/5] Opt into prebuilds of React Native dependencies --- apps/test-app/ios/Podfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/test-app/ios/Podfile b/apps/test-app/ios/Podfile index fefbbc4f..f650ecd6 100644 --- a/apps/test-app/ios/Podfile +++ b/apps/test-app/ios/Podfile @@ -1,3 +1,6 @@ +# Opt into prebuilds of RN dependencies +ENV['RCT_USE_RN_DEP'] = ENV['RCT_USE_RN_DEP'] || '1' + ws_dir = Pathname.new(__dir__) ws_dir = ws_dir.parent until File.exist?("#{ws_dir}/node_modules/react-native-test-app/test_app.rb") || From f83e32770255217eb4ee666fdee5c7c122ec1092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 14 Sep 2025 19:48:52 +0200 Subject: [PATCH 3/5] Simplify podspec --- packages/host/react-native-node-api.podspec | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/packages/host/react-native-node-api.podspec b/packages/host/react-native-node-api.podspec index 00f29e4c..5066e82d 100644 --- a/packages/host/react-native-node-api.podspec +++ b/packages/host/react-native-node-api.podspec @@ -41,26 +41,11 @@ Pod::Spec.new do |s| CMD } - # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0. + # Use install_modules_dependencies helper to install the dependencies (requires React Native version >=0.71.0). # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79. if respond_to?(:install_modules_dependencies, true) install_modules_dependencies(s) else - s.dependency "React-Core" - # Don't install the dependencies when we run `pod install` in the old architecture. - if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then - # TODO: Re-visit these dependencies and flags and remove them if not needed. - s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" - s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", - "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" - } - s.dependency "React-Codegen" - s.dependency "RCT-Folly" - s.dependency "RCTRequired" - s.dependency "RCTTypeSafety" - s.dependency "ReactCommon/turbomodule/core" - end + raise "This version of React Native is too old for React Native Node-API." end end \ No newline at end of file From 492e09c10dfc5532506a8ebfe5bc42b2db319fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 14 Sep 2025 21:22:48 +0200 Subject: [PATCH 4/5] Ensure RCT_USE_PREBUILT_RNCORE is never enabled --- packages/host/scripts/patch-hermes.rb | 4 ++++ packages/host/src/node/podspec.test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 packages/host/src/node/podspec.test.ts diff --git a/packages/host/scripts/patch-hermes.rb b/packages/host/scripts/patch-hermes.rb index 2d986e4a..9e1faaf5 100644 --- a/packages/host/scripts/patch-hermes.rb +++ b/packages/host/scripts/patch-hermes.rb @@ -1,5 +1,9 @@ Pod::UI.warn "!!! PATCHING HERMES WITH NODE-API SUPPORT !!!" +if ENV['RCT_USE_PREBUILT_RNCORE'] == '1' + raise "React Native Node-API cannot reliably patch JSI when React Native Core is prebuilt." +end + VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --silent '#{Pod::Config.instance.installation_root}'`.strip if Dir.exist?(VENDORED_HERMES_DIR) Pod::UI.info "Hermes vendored into #{VENDORED_HERMES_DIR.inspect}" diff --git a/packages/host/src/node/podspec.test.ts b/packages/host/src/node/podspec.test.ts new file mode 100644 index 00000000..4da4d640 --- /dev/null +++ b/packages/host/src/node/podspec.test.ts @@ -0,0 +1,24 @@ +import assert from "node:assert/strict"; +import { describe, it } from "node:test"; +import cp from "node:child_process"; + +describe("Podspec", () => { + // We cannot support prebuilds of React Native Core since we're patching JSI + it( + "should error when RCT_USE_PREBUILT_RNCORE is set", + // We cannot call `pod` on non-macOS systems + { skip: process.platform !== "darwin" }, + () => { + const { status, stdout } = cp.spawnSync("pod", ["spec", "lint"], { + env: { ...process.env, RCT_USE_PREBUILT_RNCORE: "1" }, + encoding: "utf-8", + }); + + assert.notEqual(status, 0); + assert.match( + stdout, + /React Native Node-API cannot reliably patch JSI when React Native Core is prebuilt/, + ); + }, + ); +}); From 798840ae6635c50fa070ce8bd085ae89d163e071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 14 Sep 2025 21:23:11 +0200 Subject: [PATCH 5/5] Revert "Add matrix with prebuilds for RN core and deps enabled" This reverts commit 86ff582d4aec60663155b7ffc5bf9e4e648a063f. --- .github/workflows/check.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b0ef321e..52aa06c7 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -76,16 +76,8 @@ jobs: - run: npm test test-ios: if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Apple 🍎') - name: Test app (iOS${{ matrix.rn-deps-prebuilds && ' / RN deps prebuilds' || '' }}${{ matrix.rn-core-prebuilds && ' / RN core prebuilds' || '' }}) + name: Test app (iOS) runs-on: macos-latest - strategy: - matrix: - rn-deps-prebuilds: - - true - - false - rn-core-prebuilds: - - true - - false steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -108,11 +100,6 @@ jobs: FERRIC_TARGETS: aarch64-apple-ios-sim - run: npm run pod-install working-directory: apps/test-app - env: - # Optionally enable experimental prebuilds - # https://reactnative.dev/blog/2025/08/12/react-native-0.81#experimental-precompiled-ios-builds - RCT_USE_PREBUILT_RNCORE: ${{ matrix.rn-core-prebuilds && '1' || '0' }} - RCT_USE_RN_DEP: ${{ matrix.rn-deps-prebuilds && '1' || '0' }} - name: Run tests (iOS) run: npm run test:ios:allTests # TODO: Enable release mode when it works