skip to Main Content

After upgrading macOS from 12.x to the latest 13.x, the build of my React Native 0.70.1 starts to throw the error above. ruby -v outputs:

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

And

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)

However if moving out of the app root directory or other directory above, ruby -v outputs:

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

The MacOS 13.x comes with ruby 2.6.8 preinstalled as it says but it was nowhere to be found on the Mac. Both react-native run-ios and pod install run successfully. However the build did fail.

Here is the related 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"
  }, 

Here is 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

2

Answers


  1. Chosen as BEST ANSWER

    After deleting pod file.lock and run pod install 2 times, the build error disappeared.


  2. The error message you’re seeing indicates that the Ruby version specified for your project (2.7.5) is not installed. You can use rbenv to manage Ruby versions and set the one required for your project.

    There is a great article by DigitalOcean on how to install specific ruby version using rbenv.

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