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") || 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 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/, + ); + }, + ); +});