Dra*_*ian 13 xcode cocoapods react-native react-native-hermes
我已经在我的react-native(v0.64)应用程序中启用了Hermes。每次我运行应用程序时,我都会得到以下堆栈跟踪。
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)
Run Code Online (Sandbox Code Playgroud)
我已经在 Podfile 中启用了 Hermes,在 pod install 后,Pods 文件夹中可以使用 pod。项目与其他项目一起采用单一存储库架构。在同一个 mono-repo 包中启用 Hermes 的另一个应用程序工作正常,没有崩溃。
播客文件:
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
Run Code Online (Sandbox Code Playgroud)
我正在使用 Xcode 12.4。
我尝试过但不起作用的解决方案:
小智 13
我在 React Native 0.70 上遇到了同样的问题
选择应用程序目标,然后按照步骤操作
其他答案建议禁用 Hermes 或手动将其添加为链接库,但这不是必需的。
最新版本应该会自动安装 Hermes 框架。
该问题似乎与使用不正确版本的 CocoaPods 和 pods 存储库有关。
要使所有内容保持最新,请执行以下操作:
GemfileReact Native 版本是最新的。您可以使用升级助手来查看是否需要更改。Gemfile. (指示)bundle installbundle exec pod repo updatePodfile.lockcd ./ios && bundle exec pod install如果仍然出现错误,请仔细检查是否实际使用了正确的版本(在您的 中PATH)。
如果您想了解更多详细信息,我还发表了一篇关于此错误的博客文章:https://traviswimer.com/blog/cocoapods-could-not-find-兼容-versions-for-pod-hermes-engine/
我更新了这个答案以使用Bundler 工具来管理 Ruby 和 Cocoapods 版本。该bundle命令现在是在 React Native 项目中使用 Cocoapods 的推荐方式。它根据项目中列出的版本运行命令Gemfile(随每个版本的 React Native 更新)。如果由于某种原因您无法使用bundle,您可以使用以下方法手动升级 Cocoapods:gem install cocoapods
然后运行其他不带bundle exec. (例如pod repo update和pod install
小智 4
尝试以下操作:
hermes_enabled为 false我尝试了几次将 hermes_enabled 从 true 更改为 false 并返回,一旦它开始工作。
| 归档时间: |
|
| 查看次数: |
8477 次 |
| 最近记录: |