Skip to content

Commit b53f84a

Browse files
authored
Enable RCT_USE_RN_DEP in test app and assert RCT_USE_PREBUILT_RNCORE != 1 (#232)
* Add matrix with prebuilds for RN core and deps enabled * Opt into prebuilds of React Native dependencies * Simplify podspec * Ensure RCT_USE_PREBUILT_RNCORE is never enabled * Revert "Add matrix with prebuilds for RN core and deps enabled" This reverts commit 86ff582.
1 parent ad2ec51 commit b53f84a

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

apps/test-app/ios/Podfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Opt into prebuilds of RN dependencies
2+
ENV['RCT_USE_RN_DEP'] = ENV['RCT_USE_RN_DEP'] || '1'
3+
14
ws_dir = Pathname.new(__dir__)
25
ws_dir = ws_dir.parent until
36
File.exist?("#{ws_dir}/node_modules/react-native-test-app/test_app.rb") ||

packages/host/react-native-node-api.podspec

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,11 @@ Pod::Spec.new do |s|
4141
CMD
4242
}
4343

44-
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
44+
# Use install_modules_dependencies helper to install the dependencies (requires React Native version >=0.71.0).
4545
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
4646
if respond_to?(:install_modules_dependencies, true)
4747
install_modules_dependencies(s)
4848
else
49-
s.dependency "React-Core"
50-
# Don't install the dependencies when we run `pod install` in the old architecture.
51-
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
52-
# TODO: Re-visit these dependencies and flags and remove them if not needed.
53-
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
54-
s.pod_target_xcconfig = {
55-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
56-
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
57-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
58-
}
59-
s.dependency "React-Codegen"
60-
s.dependency "RCT-Folly"
61-
s.dependency "RCTRequired"
62-
s.dependency "RCTTypeSafety"
63-
s.dependency "ReactCommon/turbomodule/core"
64-
end
49+
raise "This version of React Native is too old for React Native Node-API."
6550
end
6651
end

packages/host/scripts/patch-hermes.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Pod::UI.warn "!!! PATCHING HERMES WITH NODE-API SUPPORT !!!"
22

3+
if ENV['RCT_USE_PREBUILT_RNCORE'] == '1'
4+
raise "React Native Node-API cannot reliably patch JSI when React Native Core is prebuilt."
5+
end
6+
37
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --silent '#{Pod::Config.instance.installation_root}'`.strip
48
if Dir.exist?(VENDORED_HERMES_DIR)
59
Pod::UI.info "Hermes vendored into #{VENDORED_HERMES_DIR.inspect}"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import assert from "node:assert/strict";
2+
import { describe, it } from "node:test";
3+
import cp from "node:child_process";
4+
5+
describe("Podspec", () => {
6+
// We cannot support prebuilds of React Native Core since we're patching JSI
7+
it(
8+
"should error when RCT_USE_PREBUILT_RNCORE is set",
9+
// We cannot call `pod` on non-macOS systems
10+
{ skip: process.platform !== "darwin" },
11+
() => {
12+
const { status, stdout } = cp.spawnSync("pod", ["spec", "lint"], {
13+
env: { ...process.env, RCT_USE_PREBUILT_RNCORE: "1" },
14+
encoding: "utf-8",
15+
});
16+
17+
assert.notEqual(status, 0);
18+
assert.match(
19+
stdout,
20+
/React Native Node-API cannot reliably patch JSI when React Native Core is prebuilt/,
21+
);
22+
},
23+
);
24+
});

0 commit comments

Comments
 (0)