New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rn-macos's Hermes support: RNTester on 0.64 & 0.66 #952
Comments
Thanks for filing this @kelset. It seems like an issue other folks have hit as well so probably a reasonable candidate to get fixed. |
Based on the error I'm seeing in your screenshots, the extra script @ospfranco listed in #931 seems promising? |
@Saadnajmi potentially - but since that error is not present in the 0.66 branch I'm not really interested in fixing it. My main interest is understanding what it takes to make sure that Hermes works on macos :) |
Testing out react-native-macos 0.66.4 in react-native-test-app right now, and I'm getting the following linker errors with Hermes enabled:
|
It looks like the linker errors are caused by this line:
Uncommenting and rebuilding seems to work: @HeyImChris, @Saadnajmi: If there are no objections, I'll submit a PR later. |
@ospfranco I am not sure, but I think you might have to drop the extra |
I tried swapping |
If you want you can check-out the project where I'm trying to apply the update yourself |
@ospfranco in this commit ospfranco/sol@d96e551 you have put Hermes at version 0.11, not 0.9. I am not sure that will fix, but you are currently on the wrong version of Hermes |
yeah, sorry, forgot to mention, I tried with 0.9 that wasn't working to I tried with 0.11, still nothing |
@ospfranco: #982 should've fixed it. Looking at the |
I just updated to RN-macOS 0.66.10 and wanted to test if this is fixed, but I still get the same error #1021 was supposed to fix |
oops, damn, I meant |
I use the filter at the bottom. Can you also check a few more things for me:
|
Ah, apparently my pods had a cached version, I removed the Pods folder and the Podfile.lock and did a clean install (with hermes-engine 0.9.0) and it works! Thanks a lot! Also, I'm getting a Intl error, I thought hermes was supposed to add Intl support by now? :P |
According to the Hermes docs, it's only implemented on Android: https://hermesengine.dev/docs/language-features/#supported 😕 |
Summary: **Context** On Core RN, Hermes for iOS can be enabled by setting a flag in the Podfile https://reactnative.dev/docs/hermes#ios | Since React Native 0.64, Hermes also runs on iOS. To enable Hermes for iOS, edit your ios/Podfile file and make the change illustrated below: ``` use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods # By default, Hermes is disabled on Old Architecture, and enabled on New Architecture. # You can enable/disable it manually by replacing `flags[:hermes_enabled]` with `true` or `false`. :hermes_enabled => true ) ``` In the RNTester Podfile, Hermes is enabled using envvar: https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L27 ``` # Hermes is now enabled by default. # The following line will only disable Hermes if the USE_HERMES envvar is SET to a value other than 1 (e.g. USE_HERMES=0). hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1' ``` Build command: `USE_HERMES=1 bundle exec pod install` This will install the Hermes runtime Pod (not build it from scratch) & thus enable the `RCT_USE_HERMES` macro. https://www.internalfb.com/code/fbsource/[9f57823a75a40d3f8559c8f1b7ae0add8e95d6dc]/xplat/js/react-native-github/packages/rn-tester/RNTester/AppDelegate.mm?lines=10-16 --- The documentation for enabling Hermes on RN Desktop macOS are outdated: https://microsoft.github.io/react-native-windows/docs/hermes#hermes-on-macos > Install the npm package yarn add 'hermes-engine-darwin@^0.4.3' * `hermes-engine-darwin` is no longer required > Add (or uncomment) the following pod dependencies to your macOS target in your Podfile: pod 'React-Core/Hermes', :path => '../node_modules/react-native-macos/' pod 'hermes', :path => '../node_modules/hermes-engine-darwin' pod 'libevent', :podspec => '../node_modules/react-native-macos/third-party-podspecs/libevent.podspec' * Setting `USE_HERMES=1` during `pod install= replaces all of this > Copy Run pod install Be sure to set your target's deployment target to at least 10.14 before running pod install * `USE_HERMES=1 bundle exec pod install --verbose` --- On RN Desktop, the Hermes flag was [set to false](microsoft#780) due to M1 build reasons which have since been resolved. - microsoft#952 - microsoft#781 Curiously, the `RNTester-macOS` target AppDelegate was never updated to import & use Hermes when `RCT_USE_HERMES` was `true`. Only the `RNTester` for mobile had the correct Hermes usage. **RNTester-macOS:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester-macOS/AppDelegate.mm **RNTester:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester/AppDelegate.mm **Change** * Remove `pods(:hermes_enabled => true)` in favor of passing `USE_HERMES=1` to `pod install` (This is how it's done on RNTester iOS) * Copy Hermes support to `RNTester-macOS` AppDelegate Test Plan: **Install from scratch** Differential Revision: https://phabricator.intern.facebook.com/D38277077
Summary: **Context** On Core RN, Hermes for iOS can be enabled by setting a flag in the Podfile https://reactnative.dev/docs/hermes#ios | Since React Native 0.64, Hermes also runs on iOS. To enable Hermes for iOS, edit your ios/Podfile file and make the change illustrated below: ``` use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods # By default, Hermes is disabled on Old Architecture, and enabled on New Architecture. # You can enable/disable it manually by replacing `flags[:hermes_enabled]` with `true` or `false`. :hermes_enabled => true ) ``` In the RNTester Podfile, Hermes is enabled using envvar: https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L27 ``` # Hermes is now enabled by default. # The following line will only disable Hermes if the USE_HERMES envvar is SET to a value other than 1 (e.g. USE_HERMES=0). hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1' ``` Build command: `USE_HERMES=1 bundle exec pod install` This will install the Hermes runtime Pod (not build it from scratch) & thus enable the `RCT_USE_HERMES` macro. https://www.internalfb.com/code/fbsource/[9f57823a75a40d3f8559c8f1b7ae0add8e95d6dc]/xplat/js/react-native-github/packages/rn-tester/RNTester/AppDelegate.mm?lines=10-16 --- The documentation for enabling Hermes on RN Desktop macOS are outdated: https://microsoft.github.io/react-native-windows/docs/hermes#hermes-on-macos > Install the npm package yarn add 'hermes-engine-darwin@^0.4.3' * `hermes-engine-darwin` is no longer required > Add (or uncomment) the following pod dependencies to your macOS target in your Podfile: pod 'React-Core/Hermes', :path => '../node_modules/react-native-macos/' pod 'hermes', :path => '../node_modules/hermes-engine-darwin' pod 'libevent', :podspec => '../node_modules/react-native-macos/third-party-podspecs/libevent.podspec' * Setting `USE_HERMES=1` during `pod install= replaces all of this > Copy Run pod install Be sure to set your target's deployment target to at least 10.14 before running pod install * `USE_HERMES=1 bundle exec pod install --verbose` --- On RN Desktop, the Hermes flag was [set to false](#780) due to M1 build reasons which have since been resolved. - #952 - #781 Curiously, the `RNTester-macOS` target AppDelegate was never updated to import & use Hermes when `RCT_USE_HERMES` was `true`. Only the `RNTester` for mobile had the correct Hermes usage. **RNTester-macOS:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester-macOS/AppDelegate.mm **RNTester:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester/AppDelegate.mm **Change** * Remove `pods(:hermes_enabled => true)` in favor of passing `USE_HERMES=1` to `pod install` (This is how it's done on RNTester iOS) * Copy Hermes support to `RNTester-macOS` AppDelegate Test Plan: **Install from scratch** Differential Revision: https://phabricator.intern.facebook.com/D38277077 Co-authored-by: Shawn Dempsey <shawndempsey@fb.com>
Summary: **Context** On Core RN, Hermes for iOS can be enabled by setting a flag in the Podfile https://reactnative.dev/docs/hermes#ios | Since React Native 0.64, Hermes also runs on iOS. To enable Hermes for iOS, edit your ios/Podfile file and make the change illustrated below: ``` use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods # By default, Hermes is disabled on Old Architecture, and enabled on New Architecture. # You can enable/disable it manually by replacing `flags[:hermes_enabled]` with `true` or `false`. :hermes_enabled => true ) ``` In the RNTester Podfile, Hermes is enabled using envvar: https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L27 ``` # Hermes is now enabled by default. # The following line will only disable Hermes if the USE_HERMES envvar is SET to a value other than 1 (e.g. USE_HERMES=0). hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1' ``` Build command: `USE_HERMES=1 bundle exec pod install` This will install the Hermes runtime Pod (not build it from scratch) & thus enable the `RCT_USE_HERMES` macro. https://www.internalfb.com/code/fbsource/[9f57823a75a40d3f8559c8f1b7ae0add8e95d6dc]/xplat/js/react-native-github/packages/rn-tester/RNTester/AppDelegate.mm?lines=10-16 --- On RN Desktop, the Hermes flag was [set to false](microsoft#780) due to M1 build reasons which have since been resolved. - microsoft#952 - microsoft#781 Curiously, the `RNTester-macOS` target AppDelegate was never updated to import & use Hermes when `RCT_USE_HERMES` was `true`. Only the `RNTester` for mobile had the correct Hermes usage. **RNTester-macOS:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester-macOS/AppDelegate.mm **RNTester:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester/AppDelegate.mm -- The documentation for enabling Hermes on RN Desktop macOS are outdated: https://microsoft.github.io/react-native-windows/docs/hermes#hermes-on-macos > Install the npm package yarn add 'hermes-engine-darwin@^0.4.3' * `hermes-engine-darwin` npm package is no longer required > Add (or uncomment) the following pod dependencies to your macOS target in your Podfile: pod 'React-Core/Hermes', :path => '../node_modules/react-native-macos/' pod 'hermes', :path => '../node_modules/hermes-engine-darwin' pod 'libevent', :podspec => '../node_modules/react-native-macos/third-party-podspecs/libevent.podspec' * Setting `USE_HERMES=1` during `pod install` replaces these manual steps > Copy Run pod install Be sure to set your target's deployment target to at least 10.14 before running pod install * `USE_HERMES=1 bundle exec pod install --verbose` --- **Change** * Remove `pods(:hermes_enabled => true)` in favor of passing `USE_HERMES=1` to `pod install` (This is how it's done on RNTester iOS) * Copy Hermes support to `RNTester-macOS` AppDelegate Test Plan: ## Hermes Enabled ``` cd packages/rn-tester # Ensure fresh pod install & `RCT_USE_HERMES` works rm -rf Pods # Install pods USE_HERMES=1 bundle exec pod install --verbose # Note the installing of hermes-engine -> Installing hermes-engine (0.11.0) > Copying hermes-engine from `/Users/shawndempsey/Library/Caches/CocoaPods/Pods/Release/hermes-engine/0.11.0-84e3a` to `Pods/hermes-engine` # Open in xcode open RNTesterPods.xcworkspace ``` `React-hermes` should be installed {F756792783} |Connect to Hermes w/ Flipper| |https://pxl.cl/28RTj| --- ## Hermes disabled ``` bundle exec pod install --verbose ``` `React-hermes` is **not** installed {F756795691} |Herms is not active| |https://pxl.cl/28RWK| Reviewers: lyahdav, ericroz, chpurrer, #seller_expansion Reviewed By: lyahdav Differential Revision: https://phabricator.intern.facebook.com/D38277077 Tasks: T127659495 Tags: marketplace, marketplace_seller_expansion
Summary: **Context** On Core RN, Hermes for iOS can be enabled by setting a flag in the Podfile https://reactnative.dev/docs/hermes#ios | Since React Native 0.64, Hermes also runs on iOS. To enable Hermes for iOS, edit your ios/Podfile file and make the change illustrated below: ``` use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods # By default, Hermes is disabled on Old Architecture, and enabled on New Architecture. # You can enable/disable it manually by replacing `flags[:hermes_enabled]` with `true` or `false`. :hermes_enabled => true ) ``` In the RNTester Podfile, Hermes is enabled using envvar: https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L27 ``` # Hermes is now enabled by default. # The following line will only disable Hermes if the USE_HERMES envvar is SET to a value other than 1 (e.g. USE_HERMES=0). hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1' ``` Build command: `USE_HERMES=1 bundle exec pod install` This will install the Hermes runtime Pod (not build it from scratch) & thus enable the `RCT_USE_HERMES` macro. https://www.internalfb.com/code/fbsource/[9f57823a75a40d3f8559c8f1b7ae0add8e95d6dc]/xplat/js/react-native-github/packages/rn-tester/RNTester/AppDelegate.mm?lines=10-16 --- On RN Desktop, the Hermes flag was [set to false](microsoft#780) due to M1 build reasons which have since been resolved. - microsoft#952 - microsoft#781 Curiously, the `RNTester-macOS` target AppDelegate was never updated to import & use Hermes when `RCT_USE_HERMES` was `true`. Only the `RNTester` for mobile had the correct Hermes usage. **RNTester-macOS:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester-macOS/AppDelegate.mm **RNTester:** https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/RNTester/AppDelegate.mm -- The documentation for enabling Hermes on RN Desktop macOS are outdated: https://microsoft.github.io/react-native-windows/docs/hermes#hermes-on-macos > Install the npm package yarn add 'hermes-engine-darwin@^0.4.3' * `hermes-engine-darwin` npm package is no longer required > Add (or uncomment) the following pod dependencies to your macOS target in your Podfile: pod 'React-Core/Hermes', :path => '../node_modules/react-native-macos/' pod 'hermes', :path => '../node_modules/hermes-engine-darwin' pod 'libevent', :podspec => '../node_modules/react-native-macos/third-party-podspecs/libevent.podspec' * Setting `USE_HERMES=1` during `pod install` replaces these manual steps > Copy Run pod install Be sure to set your target's deployment target to at least 10.14 before running pod install * `USE_HERMES=1 bundle exec pod install --verbose` --- **Change** * Remove `pods(:hermes_enabled => true)` in favor of passing `USE_HERMES=1` to `pod install` (This is how it's done on RNTester iOS) * Copy Hermes support to `RNTester-macOS` AppDelegate Test Plan: ## Hermes Enabled ``` cd packages/rn-tester # Ensure fresh pod install & `RCT_USE_HERMES` works rm -rf Pods # Install pods USE_HERMES=1 bundle exec pod install --verbose # Note the installing of hermes-engine -> Installing hermes-engine (0.11.0) > Copying hermes-engine from `/Users/shawndempsey/Library/Caches/CocoaPods/Pods/Release/hermes-engine/0.11.0-84e3a` to `Pods/hermes-engine` # Open in xcode open RNTesterPods.xcworkspace ``` `React-hermes` should be installed {F756792783} |Connect to Hermes w/ Flipper| |https://pxl.cl/28RTj| --- ## Hermes disabled ``` bundle exec pod install --verbose ``` `React-hermes` is **not** installed {F756795691} |Herms is not active| |https://pxl.cl/28RWK| Reviewers: lyahdav, ericroz, chpurrer, #seller_expansion Reviewed By: lyahdav Differential Revision: https://phabricator.intern.facebook.com/D38277077 Tasks: T127659495 Tags: marketplace, marketplace_seller_expansion
Environment
(0.64-stable branch of this repo, fb66merge branch by @HeyImChris: https://github.com/HeyImChris/react-native-macos/tree/fb66merge)
Steps to reproduce the bug
After doing the basic
yarn
from root of the repo, I go intopackages/rn-tester
and dopod install
.Then open RNTesterPods.xcworkspace, select "RNTester-macOS" -> "My Mac" and press play.
Without any changes, it works for both 0.64 and 0.66 versions. An app is created, metro instance loaded and RNTester app is usable.
If I try to enable Hermes by going in
scripts/react_native_pods.rb
and changing L17 fromto
Note: this is quickest way of enabling Hermes, there are others but this does the work as far as I can tell. After cleaning build folder, closing Xcode, doing a new
pod install
, the hermes-engine pod also gets pulled in correctly.Then, when I open RNTesterPods.xcworkspace, select "RNTester-macOS" -> "My Mac" and press play, this time around the build fails, for both 0.64 and 0.66.
Details of the failures in the "Actual Behaviour" section.
Expected Behavior
That RNTester loads up correctly, and shows the "Hermes engine" line in the top right corner just like it happens with Android and iOS.
Actual Behavior
For 0.64
In 0.64, the build error is as shown in the screenshot:
This was a known error in 0.64, and there are issues opened about it: facebook/flipper#2281 but for some reason, updating the Flipper dependencies in the Podfile as per the resolution offered there didn't lead to the Xcode project building.
For 0.66
In 0.66 the error is different (correctly, the issue hit above is solved in this newer version). See screenshot:
This Linker level error:
Resembled another error that was reported during the RC phase of 0.66: react-native-community/releases#251
In that case, the problem was with the arm64; still, I kept digging and basically it was caused by the fact that Folly needed one extra library
c++abi
, which was added to Folly's requirements (facebook/folly@0fee9df) for Apple's Cmake but that version of Folly wasn't getting consumed by RN correctly, which lead to facebook/flipper#2600 and in turn facebook@8b6d7fdThis last commit is present in the
fb66merge
branch - so I dug a bit deeper and realized that even despite that, the dependency of Flipper-Folly had to be bumped to 2.6.10 to get the right version of Folly.I tried to do that too, but the build error is still present.
At this point I'm kind-of running out of ideas, which is why I've decided to open this to document all my findings in the hope that someone can point out what I need to do to get Hermes to work against react-native-macos's RNTester (which I hope in turn will lead to it working in any react-native-macos project).
Reproducible Demo
(see repro steps section)
Additional context
about hermes-darwin-engine
One extra rabbithole of this whole story is the extra dependency
hermes-engine-darwin
. I found it mentioned in a few places, and in the docs for RN-macos too: https://microsoft.github.io/react-native-windows/docs/hermes#hermes-on-macosBut it turns out, this entire npm package was removed entirely from the Hermes repo: facebook/hermes@dbc1e28
So I tried to understand a bit more of what that package was all about: it seems that it was created as a "quick and dirty" add on during the early stages of Hermes for iOS work: facebook/hermes#297
Then one of the Hermes developers realized that ios & macos impl could have been together here
https://github.com/facebook/hermes/pull/385/files
so it's been "hermes-engine" only since 0.7 (the version paired with 0.64).
All of this seems to point in the direction of
hermes-engine
being the only dependency needed to get Hermes to work on macos.In closure - this issue seems to be related to mine, so linking here for cross-ref: #931
The text was updated successfully, but these errors were encountered: