[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$frlXeJeGGHlsm6oIRzMIHajeooQ5Yi26wMaeXiM88Fno":3},{"code":4,"message":5,"data":6},200,"成功",{"id":7,"createdAt":8,"title":9,"content":10,"summary":11,"image":12,"uid":13,"user":14,"categoryId":21,"category":22,"subCategoryId":24,"subCategory":25,"comments":27,"status":17,"reason":28,"notice":28,"visitCount":29,"commentCount":30,"keywords":31},92,"2024-03-04T04:42:47.834Z","React-Native \"Library not loaded: @rpath/hermes.framework/hermes\" or \"dyld image not found hermes.framework\"","**前言：**\n在开发react native的过程中，有可能遇到hermes.framework没有load的问题，经过我大范围的查找资料和fix尝试，我自己项目出现的编译问题始终没有得到正确的解决。为此，我不得不寻求一个不会出现该问题的版本，经过多次的尝试，得到一个解决方案，以供大家参考。\n\n**react-native的github上的issue现状：**\nissue部分同样出现过很多这种上报的案例，但是在issue部分，往往官方团队并不能复现这种特有的情况，基本情况是不了了之，然后告诉开发者去升级最新版本。也有通过自己手动添加link library的方式解决该问题的，但是仍然还有一些开发者在issue和stackoverflow上反馈了该种类型的报错。\n\n## 具体报错：\n> Library not loaded: @rpath/hermes.framework/hermes\n\n或者：\n> dyld image not found hermes.framework... found in /var/.../hermes.framework reference in /var/....\n\n诸如此类的报错，都是hermes引擎库没有正确的被链接，或者是hermes的引擎库版本出现了兼容性的问题。因为从node_modules下的hermes-engine中可以看到hermes是被正常install得。\n\n解决这种问题的思路，经过我查阅资料和代码尝试，我做了一些解决该问题的方案总结，每个开发者可能会使用其中的某一个方法就可以解决掉。\n\n## 解决bug的前提：\n1. 如果你是将项目从低版本升级到高版本，那么你应该按照react-native的upgrade方案，修改你工程中的配置文件和代码，版本升级指南你可以进入以下网址查看：\n[https://react-native-community.github.io/upgrade-helper/](https://react-native-community.github.io/upgrade-helper/)\n或者你可以在react-native的工程目录下，运行命令`react-native upgrade`命令，同样会给出这个链接的。\n\n2. 你应该确保在你自己的电脑上，新建任意版本的react native工程是既可以运行在模拟器上，也可以运行在真实设备上。\n新建react native工程：\n```\nnpx react-native@latest init RnTestProj --verbose\n```\n跑一下模拟器（同样可以usb连接iphone进行再跑这个命令）\n```\nyarn ios --verbose\n```\n或者\n```\nreact-native run-ios --verbose\n```\n3. 在任意react native工程目录下，执行终端命令：\n```\nreact-native doctor\n```\n检测当前电脑环境中的react native运行环境都是ok的。\n\n## 解决方案\n### 方案一\n确保工程中的ruby、bundle、cocoapods、gem是最新且一致的：\n- 更新gem\n```\ngem update --system --verbose\n```\n- 更新rvm\n```\nrvm cleanup all // clean\nrvm get stable --verbose\n```\n- 安装最新ruby\n```\n// 可以查看目前所有可以安装的ruby版本\nrvm list remote\n// 安装最新\nrvm install ruby --verbose\n// 或者指定版本安装\nrvm install ruby-3.2.2 --verbose\n```\n可以查看本地已安装好的ruby版本:\n```\nrvm list known\n```\n可以使用其中的一个ruby版本作为默认版本：\n```\nrvm --default use 3.2.2\n```\n- 安装新版的cocoapods（1.15及以上除外，因为react-native官方团队说1.15以上会有集成问题，所以最好选择安装1.14.3）\n```\ngem install cocoapods -v 1.14.3 --verbose\n```\n如果按照以上步骤，那么你的Gemfile文件中的配置应该手动修改成类似如下：\n```Gemfile\nsource 'https://rubygems.org'\n\n# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version\nruby '3.2.2'\n\ngem 'cocoapods', '1.14.3'\ngem 'activesupport', '>= 6.1.7.3', '\u003C 7.1.0'\n```\n> 切记修改Gemfile后，要删除掉Gemfile.lock文件\n\n做完上面的工作，你要删除掉node_modules、yarn.lock、ios/Pods、ios/build、ios/Podfile.lock这些文件或者文件夹。\n依次执行：\n```\nyarn install --verbose\nbundle install --verbose\n// 进入ios文件夹后执行\nbundle exec pod install --verbose\n```\n然后再尝试运行在模拟器和真实设备上，查看是否解决。\n\n### 方案二\n这个方案就是将hermes.xcframework直接手动链接到工程中。\nxcode > build phases > Link binary with Libraries\n![](https://image.xinwei.ltd/11709526298940.png)\n\n这种方式有的人成功了，但不适用于我的工程。\n\n### 方案三\n在ios的文件夹目录下，通过pod命令直接升级hermes-engine\n```\npod update hermes-engine --no-repo-update\n```\n![](https://image.xinwei.ltd/21709526493150.png)\n\n### 方案四\n就是设置是否启用hermes。先将hermes禁用，安装好依赖，尝试编译运行。如果正常，那么再启用hermes，再安装依赖，尝试编译运行，看是否可以解决。\n\n启用true/禁用false\n```Podfile\n:hermes_enabled => false,\n```\n\n基本上大家的共识是，希望使用hermes，而不是禁用它。由于hermes出色的性能，能很好的优化启动速度和降低包大小，所以最终目的不是禁用它，而是看切换过程中，是否能得到某些编译方面的启示。\n\n### 最终方案\n以上的四种方案，是可以在整个互联网上找到的解决方案，可但是，对于我的项目是无效的。\n所以我自己历经辛苦，终于找到一个稳定版本，不会出现该错误。\n简介：我的项目是一个0.61.5的老项目，对于当前0.73.5的最新稳定版来讲，已经不能再正常运行了。\n步骤如下：\n1. 0.61.5 升级到 0.71.15；\n2. 使用方案一的方式，确保最新的环境；\n3. 重新安装Xcode（我的电脑目前只安装了Xcode14.2）；\n4. 重新安装所有依赖，并尝试运行到模拟器和真实设备；\n5. 最后模拟器和真实设备都运行成功了。\n最后附上我的环境配置：\n```\nreact-native info\n```\n```terminal\n ✘ hanweixing@Pirate-Hamry  ~/Desktop/AwesomeProjectII   main  react-native info\nwarn Package react-native-vector-icons contains invalid configuration: \"dependency.assets\" is not allowed. Please verify it's properly linked using \"npx react-native config\" command and contact the package maintainers about this.\ninfo Fetching system and libraries information...\nwarn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/3.2.0/gems/cocoapods-core-1.14.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via \"project.ios.sourceDir\". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md\nSystem:\n  OS: macOS 12.7.3\n  CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz\n  Memory: 33.92 MB / 8.00 GB\n  Shell:\n    version: 5.8.1\n    path: /bin/zsh\nBinaries:\n  Node:\n    version: 18.16.0\n    path: /usr/local/bin/node\n  Yarn:\n    version: 1.22.21\n    path: /usr/local/bin/yarn\n  npm:\n    version: 9.5.1\n    path: /usr/local/bin/npm\n  Watchman:\n    version: 2024.01.22.00\n    path: /usr/local/bin/watchman\nManagers:\n  CocoaPods:\n    version: 1.14.3\n    path: /Users/hanweixing/.rvm/gems/ruby-3.2.2/bin/pod\nSDKs:\n  iOS SDK:\n    Platforms:\n      - DriverKit 22.2\n      - iOS 16.2\n      - macOS 13.1\n      - tvOS 16.1\n      - watchOS 9.1\n  Android SDK: Not Found\nIDEs:\n  Android Studio: 4.2 AI-202.7660.26.42.7351085\n  Xcode:\n    version: 14.2/14C18\n    path: /usr/bin/xcodebuild\nLanguages:\n  Java:\n    version: 10.0.2\n    path: /usr/bin/javac\n  Ruby:\n    version: 3.2.2\n    path: /Users/hanweixing/.rvm/rubies/ruby-3.2.2/bin/ruby\nnpmPackages:\n  \"@react-native-community/cli\": Not Found\n  react:\n    installed: 18.2.0\n    wanted: 18.2.0\n  react-native:\n    installed: 0.71.15\n    wanted: 0.71.15\n  react-native-macos: Not Found\nnpmGlobalPackages:\n  \"*react-native*\": Not Found\nAndroid:\n  hermesEnabled: true\n  newArchEnabled: false\niOS:\n  hermesEnabled: true\n  newArchEnabled: false\n\ninfo React Native v0.73.5 is now available (your project is running on v0.71.15).\ninfo Changelog: https://github.com/facebook/react-native/releases/tag/v0.73.5\ninfo Diff: https://react-native-community.github.io/upgrade-helper/?from=0.73.5\ninfo For more info, check out \"https://reactnative.dev/docs/upgrading?os=macos\".\n```\n\n希望对大家有所帮助。\n\n\n\n","在开发react native的过程中，有可能遇到hermes.framework没有load的问题，经过我大范围的查找资料和fix尝试，我自己项目出现的编译问题始终没有得到正确的解决。为此，我不得不寻求一个不会出现该问题的版本，经过多次的尝试，得到一个解决方案，以供大家参考。","https://image.xinwei.ltd/11709526298940.png",499668042977349,{"phone":15,"userId":13,"nickName":16,"vipType":17,"avatar":18,"sign":19,"createdAt":20},"13121171998","全栈老韩",1,"https://image.xinwei.ltd/images/IMG_5430.JPG","全栈工程师，擅长iOS App开发、前端（vue、react、nuxt、小程序&Taro）开发、Flutter、React Native、后端（midwayjs、golang、express、koa）开发、docker容器、seo优化等。","2024-01-01T16:14:30.305Z",2,{"id":21,"name":23},"IT技术",12,{"id":24,"name":26,"parentId":21},"React Native",[],"",1133,0,"react native,react native herme,react native herme库"]