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

不想你离开。 提交于 2021-01-26 03:05:40

问题


While executing npx react-native init MyProject I ran into the following error:

✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.

Which seems to be related to an earlier error displayed:

checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot 
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'

XCode and its CLI seem to all run fine.

My configuration:

  • MacOS Catalina 10.15.1 (19B88)
  • NPM 6.11.3
  • React-Native 0.61.4
  • XCode 11.2.1 (11B500)

Any leads appreciated.


回答1:


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.




回答2:


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




回答3:


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.




回答4:


In my case, the link between homebrew and cocoapods had broken I'm guessing during the catalina upgrade.

Following command fixed it: brew link --overwrite cocoapods




回答5:


I resolved this issue,

The situation with me was I recently bought a new mac and installed Xcode along with my development environment.

However I forgot to configure the Xcode command line tools, when I resolved it worked fine.

so follow these simple steps (refer to the screen shot).

Xcode > Preferences > Locations

on the command line tools select the option, in my case it was Xcode 11.7 (11....)

please note that i had deleted and reinstalled brew, cocoapods and node and it did not work until configured Xcode.

please refer to the screenshot.

then run sudo npx react-native init yourProjectName




回答6:


After using the command from the selected message, I got the following error:

[!] Error installing Flipper-PeerTalk
[!] /usr/bin/git clone https://github.com/priteshrnandgaonkar/peertalk.git /var/folders/hw/0fc3vqbn4t34rk73tk1r9lwr0000gn/T/d20201016-18847-1n36woh --template= --single-branch --depth 1 --branch v0.0.3

Cloning into '/var/folders/hw/0fc3vqbn4t34rk73tk1r9lwr0000gn/T/d20201016-18847-1n36woh'...
fatal: unable to access 'https://github.com/priteshrnandgaonkar/peertalk.git/': Could not resolve host: github.com

Then I used A Khudairy's solution and it worked very well. Thanks for everyone.

(Just reporting this because, maybe, someone can find this new error on this process and now this page can be googled with this solution)




回答7:


I had this issue because I got a new M1 mac, and I found a solution based on this github issue answer and this stackoverflow answer

Everything seemed to start working when I installed the ffi gem with the terminal running in Rosetta




回答8:


Update repo then reinstall:

$ pod repo update
$ pod instal


来源:https://stackoverflow.com/questions/58934022/react-native-error-failed-to-install-cocoapods-dependencies-for-ios-project-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!