-bash: pod: command not found to solve and the pits encountered in the installation of CocoaPods

Pods have not been used for a long time, pod reports -bash: pod: command not found CocoaPods cannot be used

Encounter many pits, record them.

1. Uninstall the original CocoaPod first, sudo gem uninstall cocoapods

2. Reinstall cocoapod, enter the command sudo gem install -n /usr/local/bin cocoapods

(The command sudogem install cocoapods before 10.11 can actually be used)

报错:Error installing cocoapods: activesupport requires Ruby version >= 2.2.2. 

Literally, the Ruby version is lower than 2.2.2 and needs to be upgraded,

Upgrade Ruby

  1. Download ruby ​​source code, compile and install

  2. Use the installation package that comes with the release to install

  3. Use rvm to install, recommended, you can refer to this blog  to update Ruby on Mac-ミ安之偌素-Blog Channel-CSDN.NET

Then install CocoaPods prompt Unable to download data from http://ruby.taobao.org/-bad response Not Found 404

Taobao mirror http://ruby.taobao.org/ is invalid

I haven't tried VPN, I have been using mirroring

    a. Change the http of Taobao mirror to https

gem sources --r http://ruby.taobao.org/ before remove If you are currently using what mirror, you can use $gem sources -l to view

gem sources -a https://ruby.taobao.org/ add an available source

 gem sources -l Check if it is successful, make sure that only one you need is kept, and the others are removed

     b. Use https://gems.ruby-china.org/ as above

     c. Someone said that they saw an answer on stackoverflow and replaced the Taobao mirror with http://rubygems.org/ 

I haven't tried the third one. I compared the two mirrors. https://gems.ruby-china.org/ is based on the domestic CDN + foreign server, with less delay.

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

3. I tried pod search AFNetworking and I kept stuck in Setting up CocoaPods master repo. Due to the new installation, it means it is downloading. At this time, you can open a new terminal window and enter "cd ~/.cocoapods/" command line Jump to the cocoapods folder, and execute "du -sh *" at regular intervals to check the size of the downloaded folder 

All of them are to pull the index json etc. which supports CocoaPods to the local. It is found that using https://ruby.taobao.org/ to mirror. The cocoapods folder is only about 200M and it will be completed.

, Use gems.ruby-china.org/mirror folder has more than 800M, guess the first download is more, later search or installation etc. need to be updated faster.

 

4. After finishing, the previous window Setting up CocoaPods master repo is gone, but there are new problems

Unable to find a pod with name, author, summary, or descriptionmatching `AFNetworking`

1. Specify pod search --simple AFNetworking to search by name

2 . Recommend to use rm ~/Library/Caches/CocoaPods/search_index.json

The pod search AFNetworking prompt appears as follows:

A new search_index.json is regenerated in ~/Library/Caches/CocoaPods. And can find the resources corresponding to AFNetworking

After you need to search for other third-party libraries, you don’t need to delete the search_index.json file, just search directly

That's it.




Link: https://www.jianshu.com/p/a9e51b6f5af9
 

Guess you like

Origin blog.csdn.net/wangletiancsdn/article/details/99820337