iosreact-nativecocoapodspodfile

Unable to Pod Install on a brand new React Native Project


I am running on an M1 Mac, and after following all of the instructions here, I am unable to run any form of pod install. When I do, I am given the following error...

[!] Invalid `Podfile` file: undefined local variable or method
`min_ios_version_supported' for #<Pod::Podfile:0x000000010ed18c60>.

I've tried running bundle install followed by bundle exec pod install, but I am faced then with the same error.

I use yarn instead of npm, I've tried removing the node_modules and running yarn cache clean as per some other answer on this site, though I did not truly expect those to work.

Additionally, my Podfile does contain the needed imports at the top of the file...

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

I've even tried to just manually enter a min_ios_version_supported at 12.4 because that is what my most recent project is working on. That gave me a different error, which I fixed again with a manual value entry, but that gave me a different more complicated error, essentially telling me I am better off actually solving the issue instead of patching it.

Finally, I've tried adding the react-native.config.js file. Still receiving the same error

I've made plenty of React Native projects before, and noticed that this Podfile on my brand new project looks very different than Podfiles I've used in the past-- am I on a new version of React that is not yet optimized?


Solution

  • At Podfile, min_ios_version_supported is in

    require_relative '../node_modules/react-native/scripts/react_native_pods'
    

    So, in '../node_modules/react-native/scripts/react_native_pods', you change at line 29:

    def min_ios_version_supported
      return '12.4'
    end
    

    to

    def min_ios_version_supported
      return '13.0'
    end
    

    After that, delete Podfile.lock, Pods and pod install again!

    Good luck!