React-Native: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template

I've found a very similar error reported here, with a solution that suggested:

sudo xcode-select --switch /Applications/Xcode.app

Reading around seems to suggest that somewhere down the updates line, the XCode CLI tools path was set to an incorrect one.

Also as @bibin-jaimon suggested in the comments below, I do have multiple versions of XCode on my machine (why? because of https://stackoverflow.com/a/58329901/606351).

Anyways, problem solved.


Unfortunately the selected answer didn't work for me. I have Mac OS Catalina 10.15.4, and I have latest version of xcode Version 11.0 (11A420a). I found some suggestions to reinstall cocopods using homebrew or gem, and at first it didn't work for me, but using it as in below command worked perfectly.

sudo gem install cocoapods -n/usr/local/bin


Ali Shirazee's solution worked well for me (thanks!).

After running:

npx react-native init myAppName --template react-native-template-typescript

I got the error:

error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./myAppName/ios && pod install". CocoaPods documentation: https://cocoapods.org/

Then I went into the folder and ran pod install as suggested in the error message but still got an error during the installation of Flipper-Glog.

Finally, I've opened Xcode, went into Preferences » Location and selected Xcode 11 from the Command Line Tools select list.

Xcode » Preferences » Location
Xcode » Preferences » Location

After that, I simply ran pod install again and it all worked.