TheMilkMan
TheMilkMan

Reputation: 285

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?

Upvotes: 9

Views: 20782

Answers (5)

Vitalii Obideiko
Vitalii Obideiko

Reputation: 1943

I do not really like the idea to change something in node_modules folder. Just try to use this approach:

min_ios_versions_supported = ['13.0', min_ios_version_supported]
index_of_max = min_ios_versions_supported.each_with_index.max_by { |number, _| number.to_f }[1]
platform :ios, min_ios_versions_supported[index_of_max]

You may set any your min_ios_version_supported (here '13.0') and min_ios_version_supported (from RN) as is. Then just choose the max of them. Profit!

Upvotes: 14

enoveh
enoveh

Reputation: 143

can't we just replace Podfile with this?

platform :ios, '13.0'

The min_ios_version_supported is a managed property that depends on the version of react-native and changing it with hard coding can cause issues later on depending on your development environment.

If you need version 13.0, just specify it in your Podfile.

Upvotes: 6

Ovidiu Cristescu
Ovidiu Cristescu

Reputation: 1043

Silly me, in my case, I wanted to upgrade react native to 0.71.4 and I changed that manually in package.json. The error happened when I tried pod install before running yarn install.

Running yarn install and only then pod install fixed the issue for me. Hope this helps somebody.

Upvotes: 2

Rohit Ninawe
Rohit Ninawe

Reputation: 41

In My Case, It worked after I moved below two lines to the top of the Podfile.

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

Upvotes: 3

Mien PV
Mien PV

Reputation: 336

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!

Upvotes: 12

Related Questions