Previously: There are a lot of articles about Cocoapods on the Internet, but I think some of them are outdated and not updated in time, and some of them are very difficult to use. So I’m going to write a post about Cocoapods for beginners. I don’t want to write too many useless things about Cocoapods. If you want to find out more about how to use Cocoapods, please find out more online.

A, install,

First, it is best to check the gem source to see if your gem source is installed sudo gem sources -a gems.ruby-china.org/!!!!! Please note, it’s HTTPS now!! # to delete the sourceGem install Cocoa Pods -> : sudo gem install -n /usr/local/bin cocoapods

Search + configure Podfile

R1. Search

$ pod search AFNetworking

If you keep Setting up CocoaPods Master repo then open it open .

CMD +N: Open a terminal again and keep an eye on the download capacity of 873M

R2. Configure podfiles (there are three ways)

Method 1: Pod Init (highly recommended) Method 2: Using plug-ins (see below to install plug-ins) (Using plug-ins is recommended) Xcode-> Product ->Cocoapods -> Create/Edit Podfile (both created and modified here) and this will switch to the Podfile file and you’ll write like this: Platform :ios, “7.0” // Select pod ‘AFNetworking’ // select the third party you want to install. Create a New Podfile (not recommended). Click on the project name -> Create -> Other ->Empty ->Podfile and copy the third party you want to install and paste it here. Same effect!

Three, use,

R3. Lock a path

$CD [path] // Drag the project folder directly to terminal

R4. Update and install third parties

Pod install –verbose –no-repo-update pod install –verbose –no-repo-update pod install –verbose –no-repo-update Use pod install –help if you can’t remember.

4, common command (usually almost not use, use the first)

Look at the gem sourceSudo gem update — system#Sudo gem Clean upGem uninstall cocoapods# update package gem list

5. Cocoapods plugin

The Cocoapods plugin is available at github.com/kattrali/co… Easy to use: download, open the project, CMD +B to compile, and then restart Xcode, I don’t need to say more! It is estimated that everyone will oh! PS: R1, R2, R3 and R4 above mean Repeat. The first step is to install, do it once, and don’t worry about it in the future. If a new third party needs to be added to the project, go through R1… R4!

Ruby upgrade

RVMRVM:Ruby Version Manager,Ruby Version Manager, ruby Version Manager Including the release of Ruby and Gem library management (gemset) $curl – L get. RVM. IO | bash – s stable

After a while, the RVM is successfully installed. source ~/.bash_profile

Test whether rVM-V is properly installed

At this point, the RVM version will appear. It is not important, as long as the version appears, the RVM installation is successful.

Upgrade Ruby with RVM

View the current Ruby versionRVM list known # Install Ruby 2.2.4 $RVM install 2.2.4

After the installation is complete, Ruby -v checks to see if the installation is successful. If Ruby 2.2.4 appears, the installation is successful. Install -n /usr/local/bin cocoapods sudo gem install

Install Ruby on Brew

Install the Brew:(curl -fsSL Raw.githubusercontent.com/Homebrew/in…)”

Check out the Ruby version $ruby-v

3. Upgrade the Ruby

Brew Update will update all brew supported software versions from GitHub to ensure you can install the latest version brew install ruby

Check whether the upgrade is successful. Exit the terminal, open it again, and check the Ruby versionRevision 54768 (2016-04-26) [x86_64-darwin15]

Viii. Problems encountered:

Cocoapods error 1: Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

Do not use text editing to edit podfiles, use Xcode to edit them, or use terminal typing commands to edit them.

Using TextEdit will give you following, pod ‘Parse’, ‘~> 1.7.1’ //notice the quotes, notice the quotes, notice the quotes

Use Xcode to open Podfile and you will get correct quotes as following,pod ‘Parse’, ‘~> 1.7.1’ //notice the quotes, notice quotes, notice quotes

Terminal Commands: cd $ open -a Xcode Podfile

The dependency navigation is not used in any concrete target. The dependency navigation is not used in any concrete target

Platform :ios, ‘8.0’#use_frameworks! For example, reactiveCocoatarget ‘Cocoapods’ configuration ‘do pod’ navigation ‘end

After installing pods,pod Search AFn will appear stuck in setup. Open the terminal CD ~/.cocoapods/. + open. Then download or other parts of the kao, directly replace the cover off, search again can if still can’t find, find the path to CD/Users/XX/Library/Caches/CocoaPods/search_index json

CMD +shift+G search :~/library, then delete search_index. Json on terminal,pod setup is expected to wait for 2 minutes, and then search for it in a short time. Thank you!