facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.14k stars 24.32k forks source link

Library not loaded: @rpath/hermes.framework/hermes on iOS #34601

Closed allemanfredi closed 2 years ago

allemanfredi commented 2 years ago

Description

As soon as the app starts, it crashes.

Version

0.70.0

Output of npx react-native info

System:
    OS: macOS 12.5.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 299.79 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    Watchman: 2022.02.14.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.16 - /Library/Java/JavaVirtualMachines/jdk-11.0.16.jdk/Contents/Home/bin/javac
  npmPackages:
    @react-native-community/cli: 8.0.4 => 8.0.4 
    react: 18.2.0 => 18.2.0 
    react-native: 0.70.0 => 0.70.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Just launch npx react-native run-ios --simulator "iPhone 12" with hermes_enabled => true

Snack, code example, screenshot, or link to a repository

none

ch3rn1k commented 2 years ago

34599 same?

allemanfredi commented 2 years ago

34599 same?

it could be!

Bayramito commented 2 years ago

working if i disable hermes on Podfile

allemanfredi commented 2 years ago

working if i disable hermes on Podfile

Thanks but i would like to keep it enabled!

niyati-tanna-tark commented 2 years ago

I solved it by adding hermes.xcframework file to

xcode > build phases > Link binary with Libraries

just press to + sign and search for hermes

Screenshot 2022-09-07 at 7 03 52 PM

Add it and rebuild your app.

allemanfredi commented 2 years ago

@niyati-tanna-tark I solved by doing this.

rafaelmaeuer commented 2 years ago

I solved it by adding hermes.xcframework file to

xcode > build phases > Link binary with Libraries

just press to + sign and search for hermes

Screenshot 2022-09-07 at 7 03 52 PM

Add it and rebuild your app.

This works for builds with xcode, but not for cmd-builds like react-native uses: npx react-native run-ios any fix for this?

niyati-tanna-tark commented 2 years ago

I solved it by adding hermes.xcframework file to xcode > build phases > Link binary with Libraries just press to + sign and search for hermes Screenshot 2022-09-07 at 7 03 52 PM Add it and rebuild your app.

This works for builds with xcode, but not for cmd-builds like react-native uses: npx react-native run-ios any fix for this?

Screenshot 2022-09-12 at 10 54 00 AM

Yes in xCode you will need to Embed & Sign hermes framework and then build again using command. It will work.

kelset commented 2 years ago

As I commented here, based on the repro steps I don't get the error: https://github.com/facebook/react-native/issues/34612#issuecomment-1243574942

I'm going to close this issue unless someone can provide proper repro steps

github-actions[bot] commented 2 years ago
:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.
allemanfredi commented 2 years ago

I have fixed by putting this code within Podfile after __apply_Xcode_12_5_M1_post_install_workaround(installer)

def fix_hermes()
  path = "Pods/Target Support Files/Pods-AppName/Pods-AppName-frameworks.sh"
  lines = File.readlines(path)
  lines.insert(177, 'install_framework "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework"'+"\n")
  File.write(path, lines.join, mode: "w")
end
kelset commented 2 years ago

@allemanfredi could you help me understand why that is needed/what it does? 🤔

allemanfredi commented 2 years ago

@kelset it adds the following code to Pods-Eidoo-frameworks

install_framework "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework"
Gnative commented 2 years ago

See https://github.com/facebook/react-native/issues/34608 for fix.

noumantahir commented 1 year ago

34608

In my case app was running fine for first launch but if I close and open from launcher app was failing with same error.

Setting hermes to Embed & Sign as suggested in this comment did the trick for me. Thanks.!

Aure77 commented 1 year ago

To fix this issue you need to use the good version of ruby (used to install cocoapods...). It will fix pod dependencies linkage during pod install command. Check .ruby-version file in your repo. Ensure to re-run pod install + rebuild iOS after upgrade ruby.

You can run bundle install to check if you are running good version of ruby.

Please see RN 0.69 changelog: https://reactnative.dev/blog/2022/06/21/version-069#upgrades Ruby upgrade: https://github.com/facebook/react-native/commit/2c87b7466e098c5cd230e02b279fc7bc7a357615

kopax-polyconseil commented 1 year ago

I am out of idea that doesn't involve react-native upgrade, if you guys have any idea to share.

hokimtam commented 1 year ago

I solved it by adding hermes.xcframework file to

xcode > build phases > Link binary with Libraries

just press to + sign and search for hermes

Screenshot 2022-09-07 at 7 03 52 PM

Add it and rebuild your app.

Still work with react-native 0.70.10. Thank you so much.

shubhamguptadream11 commented 1 year ago

Cause: In node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec from react-native 0.70.0 minimum iOS deployment target is upgraded to 12.4 from 11.0.

Solution: So, I just upgraded my minimum iOS deployment target to 12.4 and it works.

I hope this helps someone!

reichert621 commented 7 months ago

Updating cocoapods to the latest version solved this issue for me! (just had to run sudo gem install cocoapods and check that pod --version was 1.15.x)

aurangs7 commented 4 months ago

The cocoapods version should be:

'cocoapods', '>= 1.13', '< 1.15'

Mentioned here: React Native Upgrade Helper