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
5 changes: 5 additions & 0 deletions .changeset/silly-mice-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-native-node-api": patch
---

Detects "pod install" from React Native MacOS apps and vendors Hermes accordingly
33 changes: 33 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,39 @@ jobs:
# TODO: Enable release mode when it works
# run: npm run test:ios -- --mode Release
working-directory: apps/test-app
test-macos:
# Disabling this on main for now, as initializing the template takes a long time and
# we don't have macOS-specific code yet
if: contains(github.event.pull_request.labels.*.name, 'MacOS 💻')
name: Test app (macOS)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/jod
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'jod' to 'iron'. The Node.js LTS codename should be 'iron'.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'jod' to 'jod' - this appears to be a typo for 'iron' (the current Node.js LTS codename).

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot you seem to be outdated on the name of the latest active LTS, please read https://nodejs.org/en/blog/release/v22.11.0 and update your instructions with a brief comment to ensure you won't make that mistake again.

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"
# Install CMake 3 since 4.x may have compatibility issues with Hermes build system
- name: Install compatible CMake version
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: "3.31.2"
- run: rustup target add x86_64-apple-darwin
- run: npm ci
- run: npm run bootstrap
env:
CMAKE_RN_TRIPLETS: arm64;x86_64-apple-darwin
FERRIC_TARGETS: aarch64-apple-darwin,x86_64-apple-darwin
- run: npm run init-macos-test-app
- run: pod install --project-directory=macos
working-directory: apps/macos-test-app
- name: Run MacOS test app
run: npm run test:allTests -- --mode Release
working-directory: apps/macos-test-app
test-android:
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Android 🤖')
name: Test app (Android)
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_modules/
dist/

*.tsbuildinfo

# Treading the MacOS app as ephemeral
apps/macos-test-app
13 changes: 12 additions & 1 deletion apps/test-app/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { makeMetroConfig } = require("@rnx-kit/metro-config");
module.exports = makeMetroConfig({

const config = makeMetroConfig({
transformer: {
getTransformOptions: async () => ({
transform: {
Expand All @@ -9,3 +10,13 @@ module.exports = makeMetroConfig({
}),
},
});

if (config.watchFolders.length === 0) {
// This patch is needed to locate packages in the monorepo from the MacOS app
// which is intentionally kept outside of the workspaces configuration to prevent
// duplicate react-native version and pollution of the package lock.
const path = require("node:path");
config.watchFolders.push(path.resolve(__dirname, "../.."));
}

module.exports = config;
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default tseslint.config(
{
files: [
"apps/test-app/*.js",
"apps/macos-test-app/*.js",
"packages/node-addon-examples/**/*.js",
"packages/host/babel-plugin.js",
"packages/host/react-native.config.js",
Expand All @@ -68,6 +69,7 @@ export default tseslint.config(
},
{
files: [
"**/metro.config.js",
"packages/gyp-to-cmake/bin/*.js",
"packages/host/bin/*.mjs",
"packages/host/scripts/*.mjs",
Expand Down
27 changes: 14 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"test": "npm test --workspace react-native-node-api --workspace cmake-rn --workspace gyp-to-cmake --workspace node-addon-examples",
"bootstrap": "node --run build && npm run bootstrap --workspaces --if-present",
"prerelease": "node --run build && npm run prerelease --workspaces --if-present",
"release": "changeset publish"
"release": "changeset publish",
"init-macos-test-app": "node scripts/init-macos-test-app.ts"
Copy link

Choose a reason for hiding this comment

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

Bug: Fix TypeScript entrypoint in macOS test script

The new script "init-macos-test-app" runs a TypeScript file with plain Node ("node scripts/init-macos-test-app.ts"). Node cannot execute .ts files without a loader/transpiler (e.g., tsx). This will fail at runtime, and the CI step "npm run init-macos-test-app" in the new macOS workflow will break. Use "tsx scripts/init-macos-test-app.ts" or provide a compiled JS entrypoint.

Fix in Cursor Fix in Web

},
"author": {
"name": "Callstack",
Expand Down Expand Up @@ -64,6 +65,7 @@
"globals": "^16.0.0",
"prettier": "^3.6.2",
"react-native": "0.81.4",
"read-pkg": "^9.0.1",
"tsx": "^4.20.5",
"typescript": "^5.8.0",
"typescript-eslint": "^8.38.0"
Expand Down
1 change: 0 additions & 1 deletion packages/host/react-native-node-api.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/callstackincubator/react-native-node-api.git", :tag => "#{s.version}" }

s.source_files = "apple/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}", "weak-node-api/include/*.h", "weak-node-api/*.hpp"
Expand Down
12 changes: 11 additions & 1 deletion packages/host/scripts/patch-hermes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@
raise "React Native Node-API cannot reliably patch JSI when React Native Core is prebuilt."
end

def get_react_native_package
if caller.any? { |frame| frame.include?("node_modules/react-native-macos/") }
return "react-native-macos"
elsif caller.any? { |frame| frame.include?("node_modules/react-native/") }
return "react-native"
else
raise "Unable to determine React Native package from call stack."
end
end

if ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR'].nil?
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --silent '#{Pod::Config.instance.installation_root}'`.strip
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --react-native-package '#{get_react_native_package()}' --silent '#{Pod::Config.instance.installation_root}'`.strip
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The method call uses unnecessary parentheses. In Ruby, get_react_native_package() should be written as get_react_native_package when calling methods without arguments.

Suggested change
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --react-native-package '#{get_react_native_package()}' --silent '#{Pod::Config.instance.installation_root}'`.strip
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --react-native-package '#{get_react_native_package}' --silent '#{Pod::Config.instance.installation_root}'`.strip

Copilot uses AI. Check for mistakes.
# Signal the patched Hermes to React Native
ENV['BUILD_FROM_SOURCE'] = 'true'
ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR'] = VENDORED_HERMES_DIR
Expand Down
Loading
Loading