Reprint Please specify source: http://blog.csdn.net/whjForWork/article/details/44967891
What is Cocoapods?
When you need to use a third-party open source class library in an iOS project, or if the class library you are using needs to be updated, it is cumbersome to re-download it, but with cocoapods, we can solve the problem with a single line of command.
CocoaPods is a tool for managing third-party open source code in iOS projects, cocoa using Ruby, whose source code is open source on GitHub https://github.com/CocoaPods/CocoaPods
Cocoapods can save time in setting up and updating third-party open source libraries and increase productivity
Introduction to the use of cocoapods
- GEM is a standard package for managing Ruby libraries and programs that can be found, loaded and unloaded by gems
Installing Cocoapods
- First enter the following command in the terminal,
- sudo gem sources–remove https://rubygems.org/
- After the reaction, enter the following line
- sudo gem sources-a http://ruby.taobao.org/
- Then enter this line to view the address
If a prompt similar to the following appears, represent OK
Install the Cocoapods Toolkit, enter the following command in the terminal, the installation process due to network problems will be slow, please wait patiently
- sudo gem install Cocoapods
Enter the following command in the terminal, initialize
In the terminal input pod search AFN, you can see the version of the framework, download the GIT address
If the installation is not successful, upgrade the gem
Project using pods to create a new project using Xcode
Terminal switch to project using POD init to create a podfile file
Edit the Podfile file, enter the sudo vi podfile, and then import the AFN frame as shown in the left image and save
? * then enter pod install to add the relevant framework to the project, before executing the command, the Xcode and the simulator are closed
The following prompt appears, the representative has been integrated into your project, due to network reasons, may download a bit slow
Then open the Pods demo. Xcworkspace to run the project, remember not to open the pods demo. Xcodeproj
All dependencies have been added and we are going to import the header file to use
Note The format of the import header file can only be imported using angle brackets
Summarize:
Pods all dependencies are configured according to the Podfiles file
To configure the framework, you can specify the configuration number pod ' Sdwebimage ', ' ~> 0.2.0 ', but not usually specified, and the most recent version number used
When there is a framework update, switch to the project at the terminal, and then run the pod Update command to
If you are appending a third-party framework, search the framework, and then write Podfile, using the pod Install command
The following are the common gem commands
????????????????????
Third-party class library management tools in iOS development-cocoapods-