preparation

software version
MacOS Mojeva 10.14.6
xcode 11.3.1 c504 (11)

1. Run the installation command

sudo gem install -n /usr/local/bin cocoapods
Copy the code

The following message is displayed after the installation is successful:The above is a solution to avoid the following errors:

ERROR: Could not find a valid gem 'cocoapods'(> = 0)in any repository
Copy the code

2. Install RVM

curl -L get.rvm.io | bash -s stable
Copy the code

2.1 Test whether the RVM is successfully installed

rvm -v
Copy the code

The version here is 1.29.9

2.2 Upgrading Ruby with RVM

2.2.1 Viewing the Ruby Version

ruby -v
Copy the code

2.2.2 List the available Ruby versions

rvm list known
Copy the code

Then install ruby

RVM install 2.6Copy the code

2.3 Replacing a Ruby Image

2.3.1 Checking the Current Mirror

gem sources -l
Copy the code

2.3.2 Removing a Mirror

Remove sources based on the actual situation in the previous step. If the source does not exist, you do not need to perform this step. If no output is displayed under CURRENT Sources in the preceding figure, the source has been removed.

gem sources --remove https://rubygems.org/
Copy the code

2.3.3 Replacing a Mirror

gem sources --add https://gems.ruby-china.com/
Copy the code

2.3.4 Checking whether the new image is successfully installed

gem sources -l
Copy the code

3. Install CocoaPods

sudo gem install -n /usr/local/bin cocoapods
Copy the code

You already have Cocoapods installed on this machine, so the installation is a quick success.

3.1 Downloading the Configuration File

3.1.1 method a

You can view the installation progress

pod setup --verbose
Copy the code

3.1.2 method 2

No progress is displayed. See the following figure for the progress display. Method to check download progressOpen a new terminal window and enter

cd ~/.cocoapods/ 
Copy the code

Run du -sh * to check the folder size a. If the folder size remains unchanged during the download process, you may need to delete the master branch sudo rm -fr ~/. Cocoapods /repos/master b. If the download speed is slow and errors occur during the pod Setup process using a common network, you are advised to use a 4G hotspot to download the POD setup to a MAC PC. C. A total of 300+M, using A 4G hotspot can be downloaded in about two minutes, installation takes 2-3 minutes, nearly 1G after installation

At this point, wait until Cocoapods is installed.

The result after completion is as follows:This is how to install CocoaPods.