CocoaPods

Introduction to the

CocoaPods is a third-party library management tool for iOS projects

CocoaPods is implemented in Ruby, and you need a Ruby environment to use it. Although The Mac system can run Ruby by default. However, the Ruby version is too low to support CocoaPods properly

To viewrubyversion

If ruby is older than 2.2.2, you need to upgrade ruby.
# Since my version is 2.3.7, there is no need to upgrade
ruby -v
Copy the code

Gem Ruby

  • Gem Gem is Ruby package management tools, Ruby plug-ins are installed through Gem, CocoaPods is Ruby development of a plug-in.

  • If you want to install CocoaPods using gems, you are advised to update the Gem version of CocoaPods.

To viewGemversion

 gem --version ||  gem -v
Copy the code

Gemupgrade

# Gem update, this is to solve the problem that the Gem version is too old to install Cocoapods
sudo gem update --system
Copy the code

GemUpdate all plug-ins

# Gem Update all plugins
sudo gem update
Copy the code

GemClearing expired plug-ins

# Remove expired plug-ins
sudo gem cleanup
Copy the code

CocoaPods installation

It is recommended to install after changing the source otherwise it will be very slow

Replace the Ruby source

// View the existing source gemsource -l// remove gem sources --remove https://rubygems.org/ // add ruby- China source gem sources-a https://gems.ruby-china.org/
Copy the code

CocoaPodsInstall command

sudo gem install cocoapods
Copy the code

In the same way, https://gems.ruby-china.com can be changed back to https://rubygems.org/

To viewCocoapodsversion

pod -- version
Copy the code

If the version number is displayed, the installation is successful.

The installationCocoapodswarehouse

Switch source to install repO

Remove the original warehouse image
pod repo remove master

Install to the local CD ~/.cocoapods/repos/master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git 
Copy the code

Finally, we need to setup

pod setup
Copy the code

Viewing warehouse Information

pod repo 
Copy the code

Pay attention to

The Podfile header can be ignored when used

source https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
Copy the code

–no-repo-update`

When we run pod update, we will still be asked to update the repO. We can do this by executing pod update –verbose –no-repo-update.