Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/test-app/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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") ||
Expand Down
19 changes: 2 additions & 17 deletions packages/host/react-native-node-api.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines -49 to -64
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by deleting this as we don't support old versions of React Native anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the output when users try on an unsupported version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An error is raised:

This version of React Native is too old for React Native Node-API

raise "This version of React Native is too old for React Native Node-API."
end
end
4 changes: 4 additions & 0 deletions packages/host/scripts/patch-hermes.rb
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
24 changes: 24 additions & 0 deletions packages/host/src/node/podspec.test.ts
Original file line number Diff line number Diff line change
@@ -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/,
);
},
);
});
Loading