skip to Main Content

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:

  1. Clean Pods and npm packages, clean previous build and rebuild
  2. Clear watchman and metro bundler cache and rebuild

5

Answers


  1. Try following:

    1. Change hermes_enabled value from true to false in Podfile
    2. Reinstall npm/yarn dependencies by (yarn install)
    3. Reinstall pods (cd ios && pods install)
    4. Run app (react-native run-ios)

    I tried this a couple of times changing hermes_enabled from true to false and back, and once it starts working.

    Login or Signup to reply.
  2. This resolved my issue in RN 0.70. In Xcode, Targets -> Build Phases -> Link Binary With Libraries

    enter image description here

    Login or Signup to reply.
  3. I was facing the same problem on react native 0.70

    Select App Target then follow the steps

    • goto Build Phases
    • Inside Link Binary With Libraries section
    • Click on Add Items and search for hermes.xcframework and add it
    • Rebuild application

    enter image description here

    Login or Signup to reply.
  4. 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:

    1. Make sure your Gemfile is up to date for your version of React Native. You can use the Upgrade Helper to see if it needs changed.
    2. Upgrade Ruby to the version listed in your project’s Gemfile. (Instructions)
    3. Upgrade CocoaPods to the latest version: bundle install
    4. Update the CocoaPods repo: bundle exec pod repo update
    5. Delete Podfile.lock
    6. Reinstall pods 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’s Gemfile (which is updated with each version of React Native). If for some reason you are unable to use bundle, you can manually upgrade Cocoapods using: gem install cocoapods

    Then run the other commands without bundle exec. (e.g. pod repo update and pod install

    Login or Signup to reply.
  5. 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 your Podfile (ios/Podfile), look for hermes_enabled and set its value to true. The line should look like the following

    :hermes_enabled => true
    

    Besides that, you might needs to follow few more steps from the official page.

    If your Podfile does not have any hermes_enabled property, please make sure your react-native project is using at least 0.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 running pod install from inside your ios folder.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search