microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.37k stars 130 forks source link

Can't enable hermes #1859

Open neo773 opened 1 year ago

neo773 commented 1 year ago

Environment

react-native -v: 10.2.4
npm ls react-native-macos: 
discord_rn@0.0.1 /Users/neo/Documents/temp/discord_rn
└── react-native-macos@0.71.11
node -v: v18.12.1
npm -v: 8.19.2
yarn --version: 1.22.19
xcodebuild -version:
Xcode 14.3.1
Build version 14E300c

Steps to reproduce the bug

Hi, I was trying to enable hermes by following the docs But I get these errors

[!] There are multiple dependencies with different sources for `libevent` in `Podfile`:
- libevent (from `../node_modules/react-native-macos/third-party-podspecs/libevent.podspec`)
- libevent (~> 2.1.12)
[!] The 'Pods-discord_rn-macOS' target has frameworks with conflicting names: hermes.framework.

Expected Behavior

No response

Actual Behavior

No response

Reproducible Demo

No response

Additional context

No response

Saadnajmi commented 1 year ago

Hi, I think the docs are out of date, and you just need to do the normal setup steps, with one addition: When you run pod install, run USE_HERMES=1 pod install Can you let me know if that works?

neo773 commented 1 year ago

Hi, I think the docs are out of date, and you just need to do the normal setup steps, with one addition: When you run pod install, run USE_HERMES=1 pod install Can you let me know if that works?

That didn't work then I tried manually setting :hermes_enabled to true but it errored out when I ran USE_HERMES=1 pod install

 /usr/bin/curl -f -L -o /var/folders/_k/jhw1fddx4ml1wl__9b55mqy00000gn/T/d20230624-72825-1uh9cw6/file.tgz https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.14/react-native-artifacts-0.71.14-hermes-ios-debug.tar.gz --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.11.3 cocoapods-downloader/1.6.3'
Saadnajmi commented 1 year ago

Hi, I think the docs are out of date, and you just need to do the normal setup steps, with one addition: When you run pod install, run USE_HERMES=1 pod install Can you let me know if that works?

That didn't work then I tried manually setting :hermes_enabled to true but it errored out when I ran USE_HERMES=1 pod install

 /usr/bin/curl -f -L -o /var/folders/_k/jhw1fddx4ml1wl__9b55mqy00000gn/T/d20230624-72825-1uh9cw6/file.tgz https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.14/react-native-artifacts-0.71.14-hermes-ios-debug.tar.gz --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.11.3 cocoapods-downloader/1.6.3'

I think what's happening is it's trying to download a prebuilt tarball given a React Native version, but our versions don't match React Native upstream, so "0.71.14" doesn't exist. At the current moment, I think you'll have to download Hermes separately, then pass the tarball path to HERMES_ENGINE_TARBALL_PATH like in the PR notes here: https://github.com/microsoft/react-native-macos/pull/1780

shwanton commented 1 year ago

The pre-built Hermes binaries are on Maven Central

I look at the list of latest Hermes releases & find the one that is closest to the macOS release you are using: ie. 0.71.12 The url should look like this (note the release # is in 2 places): https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.12/react-native-artifacts-0.71.12-hermes-ios-debug.tar.gz

Download the tarball to your local machine. Use this url in your pod install

HERMES_ENGINE_TARBALL_PATH=/path/to/tarball/react-native-artifacts-0.71.12-hermes-ios-debug.tar.gz pod install --verbose

The versions might not line up perfectly, but RN upgrades are much more common than Hermes 😅

eablokker commented 6 months ago

I'm also having issues enabling Hermes in 0.73

I installed the hermes-engine-darwin NPM package like the docs said.

"dependencies": {
  "hermes-engine-darwin": "^0.5.3",
  "react": "18.2.0",
  "react-native": "0.73.2",
  "react-native-macos": "^0.73.0-0"
},

I set :hermes_enabled => true, in the Podfile and run USE_HERMES=1 pod install.

I get this error:

  ...
  Installing hermes-engine (0.73.6)
Installing libevent (2.1.12)
[!] The 'Pods-ReactNativeMacos-macOS' target has frameworks with conflicting names: hermes.framework.
bear-ei commented 1 month ago

0.73.0 Is there any way to enable Hermes now?