错误构建:在 MacOS 13.3/Xcode 14 上找不到框架 Hermes

问题描述 投票:0回答:4

将 macOS 从 12.x 升级到最新的 13.x 后,我的 React Native 0.70.1 的构建开始抛出上述错误。

ruby -v
输出:

rbenv: version `2.7.5' is not installed (set by /Users/macair/documents/code/js/myapp/.ruby-version)

还有

brew -v
Homebrew 3.6.12
Homebrew/homebrew-core (git revision 1d7a7a30898; last commit 2022-11-22)
Homebrew/homebrew-cask (git revision c0c877a95b; last commit 2022-11-22)

但是,如果移出应用程序根目录或上面的其他目录,

ruby -v
输出:

ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

MacOS 13.x 正如其所说预装了 ruby 2.6.8,但在 Mac 上却找不到它。 react-native run-ios 和 pod install 都运行成功。然而构建确实失败了。

这里是相关的package.json:

"dependencies": {
    "@ethersproject/shims": "^5.7.0",
    "@react-native-community/toolbar-android": "^0.2.1",
    "@react-native-masked-view/masked-view": "^0.2.7",
    "@react-native-picker/picker": "^2.4.4",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/stack": "^6.3.1",
    "appcenter": "^4.4.5",
    "appcenter-analytics": "^4.4.5",
    "appcenter-crashes": "^4.4.5",
    "crypto-js": "^4.1.1",
    "ethers": "^5.7.1",
    "react": "18.1.0",
    "react-native": "0.70.1",
    "react-native-blob-util": "^0.16.2",
    "react-native-code-push": "^8.0.1",
    "react-native-confirmation-code-field": "^7.3.0",
    "react-native-device-info": "^10.2.0",
    "react-native-easy-grid": "^0.2.2",
    "react-native-elements": "^3.4.2",
    "react-native-encrypted-storage": "^4.0.2",
    "react-native-gesture-handler": "^2.6.1",
    "react-native-get-random-values": "^1.8.0",
    "react-native-gifted-chat": "^1.0.4",
    "react-native-image-picker": "^4.10.0",
    "react-native-loading-spinner-overlay": "^3.0.1",
    "react-native-modal": "^13.0.1",
    "react-native-reanimated": "^3.1.0",
    "react-native-redash": "^18.1.0",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^4.3.4",
    "react-native-screens": "^3.17.0",
    "react-native-vector-icons": "^9.2.0",
    "react-native-video": "^5.2.1",
    "react-native-webview": "^12.0.2",
    "rn-alioss": "^0.2.5",
    "socket.io-client": "^4.5.2"
  },
  "devDependencies": {
    "@babel/core": "^7.19.1",
    "@babel/runtime": "^7.19.0",
    "@react-native-community/eslint-config": "^3.1.0",
    "@testing-library/react-native": "^11.1.0",
    "babel-jest": "^29.0.3",
    "eslint": "^8.23.1",
    "jest": "^29.0.3",
    "metro-react-native-babel-preset": "^0.72.1",
    "react-test-renderer": "18.1.0"
  }, 

这是 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, '13'  #12.4
install! 'cocoapods', :deterministic_uuids => false

target 'xyz_app6' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'xyz_app6Tests' do
    inherit! :complete
    # Pods for testing
  end

  #post_install do |installer|
    #installer.pods_project.targets.each do |target|
      #target.build_configurations.each do |config|
      # some older pods don't support some architectures, anything over iOS 11 resolves that
      #  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' #'12.0'
      #end
    #end
  #end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

  end
end
xcode react-native
4个回答
2
投票

删除 pod file.lock 并运行 pod install 2 次后,构建错误消失。


1
投票

您看到的错误消息表明未安装为您的项目指定的 Ruby 版本 (2.7.5)。您可以使用 rbenv 来管理 Ruby 版本并设置您的项目所需的版本。

DigitalOcean 有一篇很棒的文章,介绍了如何使用 rbenv 安装特定的 ruby 版本。


0
投票
我遇到了同样的问题,并找到了 2 个解决方案来解决这个问题。

1.解决方案(最快)

更新以下 React Native 配置文件:


    .ruby 版本
  • 宝石档案
并将版本号更改为您当前的ruby版本号(ruby -v)

2.解决方案

安装所需的ruby版本(2.7.5)并将其更改为全局版本。您可能还必须再次为此 ruby 版本安装 pod。最后最好启动一个新的终端会话,以便重新加载/采用 rbenv 的更改

rbenv install 2.7.5 rbenv global 2.7.5 sudo gem install cocoapods
安装 2.7.5 并将其设置为全局后,请确保在安装 cocoapods 之前“ruby -v”打印出此版本。对我来说,我必须稍等一下,然后开始一个新的终端会话。


0
投票
这只是 Pod 问题。重新安装 Pod 将解决 Hermes 错误。请按照以下步骤操作:

    使用
  1. cd ios 进入您的 ios 文件夹
  2. 运行
  3. pod deintegrate
  4. 然后运行
  5. pod install
重建项目。

© www.soinside.com 2019 - 2024. All rights reserved.