First, we need to install POD on our computer, enter the command line, and enter the following command
sudo gem install cocoapods
Since it is an installation operation, we need sudo to obtain administrator privileges. After pressing Enter, we will see the word password, enter the password of our computer.
![](http://dl2.iteye.com/upload/attachment/0126/6152/3286d33c-fda8-3268-a20b-75b952e406bf.jpg)
Then , the computer will automatically install POD and
![](http://dl2.iteye.com/upload/attachment/0126/6156/8f05e65c-ab5f-3521-b966-c55239b1a2e1.jpg)
see "20 gems installed" to indicate the installation. finished. The following is the operation of how to integrate POD into our project.
Step1:
We first create a project and name it "POD test"
![](http://dl2.iteye.com/upload/attachment/0126/6158/c89fbfd7-f726-3c26-b72c-5b467a0a4760.jpg)
Step2: Enter
the current project folder in the command line.
:
cd + space + file name = enter the folder
cd + space + .. = return to the previous directory
pwd view the current directory
![](http://dl2.iteye.com/upload/attachment/0126/6160/60fada43-8042-3eee-a93b-bb394ab4e176.jpg)
Step3:
Enter the command to view the help to view the help
pod --help
![](http://dl2.iteye.com/upload/attachment/0126/6162/8110f3c6-d81e-3525-a21a-3a29724ad9dd.jpg)
Step4:
Initialize POD
pod init
Step5:
View all file directories under the current file
ls -al
![](http://dl2.iteye.com/upload/attachment/0126/6164/ca97446b-1cf9-3b8d-9847-e4656053823d.jpg)
We will find that there is a file called Podfile, we use the vi compiler to modify it, add the frameworks and plugins we need,
![](http://dl2.iteye.com/upload/attachment/0126/6166/9b54b972-64cd-348e-bb47-194ef467d797.jpg)
enter the following statement to edit the Podfile file
came Podfile
![](http://dl2.iteye.com/upload/attachment/0126/6168/4f8fa060-3c15-3de8-95a2-24618816ca6c.jpg)
Press "i" to enter the editing mode, move the cursor to the desired position, and enter the following command
under 'AFNetworking', '~> 2.5'
![](http://dl2.iteye.com/upload/attachment/0126/6170/a85bc9d6-e906-33ee-82a3-70293bffa2ef.jpg)
Press "esc"+"shift"+":" to exit the editing mode,
enter "wq", press Enter, and exit the vi compiler
Step6:
Enter the following statement to prepare for installation
pod install
![](http://dl2.iteye.com/upload/attachment/0126/6172/7c320bea-ca21-35a8-bbd5-ad4bc6dcd8ad.jpg)
As a result, this situation occurs. According to the prompt, it is because the Xcode of my current project is not closed, and Xcode cannot be opened during installation, so let's close Xcode first and do
it again.
pod install
![](http://dl2.iteye.com/upload/attachment/0126/6174/77f8b3b6-c780-36f1-80a4-bb62c53e8254.jpg)
Now the installation is successful.
Let's check the folder directory of our project and we
![](http://dl2.iteye.com/upload/attachment/0126/6176/bec07d25-b51b-3cfb-b806-c2ad19e42003.jpg)
will find an additional workspace project. Yes, it is this guy. Our original project is still there. If we want to use a project that integrates POD in the future, we must use the workspace project.
Then we can use the library we installed.