I have enabled Hermes in my react-native(v0.64) Application. Everytime I run app I get following stack trace.
dyld: dyld cache load error: shared cache file open() failed
dyld: Library not loaded: @rpath/hermes.framework/hermes
Referenced from: /Users/sharktank/Library/Developer/CoreSimulator/Devices/A32F4931-51A8-4D22-AEFB-625F834CE221/data/Containers/Bundle/Application/71773888-08D5-4B82-9545-07F6B1538864/COSPM-DEV.app/COSPM-DEV
Reason: image not found
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/sharktank/Library/Developer/CoreSimulator/Caches/dyld/20E232/com.apple.CoreSimulator.SimRuntime.iOS-14-4.18D46
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/sharktank/Library/Developer/Xcode/DerivedData/COSPM-atbujvbobdbyehckyoqrdgmqiubm/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSim
(lldb)
I have enabled hermes in Podfile and after pod install pod is available in Pods folder.
Project is in monorepo architecture along side another projects. Another app enabled with Hermes in same mono-repo package is working fine without crash.
Podfile:
require_relative '../../../node_modules/react-native/scripts/react_native_pods'
require_relative '../../../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'COSPM' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
pod 'RNVectorIcons', :path => '../../../node_modules/react-native-vector-icons'
# Firebase
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'CodePush', :path => '../../../node_modules/react-native-code-push'
target 'COSPMTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
I am using Xcode 12.4.
Solutions I tried which did not work:
- Clean Pods and npm packages, clean previous build and rebuild
- Clear watchman and metro bundler cache and rebuild
5
Answers
Try following:
hermes_enabled
value from true to false in PodfileI tried this a couple of times changing hermes_enabled from true to false and back, and once it starts working.
This resolved my issue in RN 0.70. In Xcode, Targets -> Build Phases -> Link Binary With Libraries
I was facing the same problem on react native 0.70
Select App Target then follow the steps
The other answers suggest disabling Hermes or manually adding it as a linked library, but this should not be necessary.
The latest version should install the Hermes framework automatically.
The problem seems to be related to using the incorrect version of CocoaPods and the pods repo.
To bring everything up to date, do the following:
Gemfile
is up to date for your version of React Native. You can use the Upgrade Helper to see if it needs changed.Gemfile
. (Instructions)bundle install
bundle exec pod repo update
Podfile.lock
cd ./ios && bundle exec pod install
If you’re still getting errors, double check that the correct versions are actually being used (are in your
PATH
).I also made a blog post about this error if you would like more details: https://traviswimer.com/blog/cocoapods-could-not-find-compatible-versions-for-pod-hermes-engine/
Update (Jan 17, 2023)
I updated this answer to use the Bundler tool to manage Ruby and Cocoapods versions. The
bundle
command is now the recommended way to use Cocoapods in React Native projects. It runs commands based on the versions listed in your project’sGemfile
(which is updated with each version of React Native). If for some reason you are unable to usebundle
, you can manually upgrade Cocoapods using:gem install cocoapods
Then run the other commands without
bundle exec
. (e.g.pod repo update
andpod install
The right answer depends on your react-native version
This error means that your react-native project is set to use
hermes
a lightweight Javascript engine created by facebook specially for react-native. It is supposed to make the app faster and lighter.If you want to use
hermes
, open yourPodfile
(ios/Podfile
), look forhermes_enabled
and set its value totrue
. The line should look like the followingBesides that, you might needs to follow few more steps from the official page.
If your
Podfile
does not have anyhermes_enabled
property, please make sure your react-native project is using at least0.60
.For react-native > 0.60 and < 0.70
For react-native >= 0.70
Hermes is the default engine for this version and beyond. Maybe you just need to reinstall your node packages, clean your
Podfile.lock
and reinstall your pods by runningpod install
from inside yourios
folder.