Skip to content
Closed
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
9 changes: 9 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ See the [README.md](../README.md#packages) for detailed descriptions of each pac
- Android: `*.android.node/` with jniLibs structure + `react-native-node-api-module` marker file
- iOS: `*.apple.node` (XCFramework renamed) + marker file

## Node.js Version

This project uses **Node.js v22.x LTS "Jod"** (became LTS on October 29, 2024). The previous LTS was v20.x "Iron".

**Important**: When reviewing CI workflows or suggesting Node.js version changes:
- The current active LTS codename is "Jod" (v22.x), not "Iron" (v20.x)
- Use `lts/jod` (lowercase) in GitHub Actions workflow files
- Check https://nodejs.org/en/about/previous-releases for the latest LTS information

## Essential Workflows

### Development Setup
Expand Down
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
- 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"
},
"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
# Signal the patched Hermes to React Native
ENV['BUILD_FROM_SOURCE'] = 'true'
ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR'] = VENDORED_HERMES_DIR
Expand Down
Loading