Skip to content

Commit f83c5c5

Browse files
committed
Update Podspec to detect React Native package name
1 parent 97c5c36 commit f83c5c5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.changeset/silly-mice-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-native-node-api": patch
3+
---
4+
5+
Detects "pod install" from React Native MacOS apps and vendors Hermes accordingly

packages/host/scripts/patch-hermes.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@
44
raise "React Native Node-API cannot reliably patch JSI when React Native Core is prebuilt."
55
end
66

7+
def get_react_native_package
8+
if caller.any? { |frame| frame.include?("node_modules/react-native-macos/") }
9+
return "react-native-macos"
10+
elsif caller.any? { |frame| frame.include?("node_modules/react-native/") }
11+
return "react-native"
12+
else
13+
raise "Unable to determine React Native package from call stack."
14+
end
15+
end
16+
717
if ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR'].nil?
8-
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --silent '#{Pod::Config.instance.installation_root}'`.strip
18+
VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --react-native-package '#{get_react_native_package()}' --silent '#{Pod::Config.instance.installation_root}'`.strip
919
# Signal the patched Hermes to React Native
1020
ENV['BUILD_FROM_SOURCE'] = 'true'
1121
ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR'] = VENDORED_HERMES_DIR

0 commit comments

Comments
 (0)