1. Installation Method
Main Command: sudo gem install cocoapods
Bytes ------------------------------------------------------------------------------------------------------------------------------
Run the following commands in the terminal:
$ gem sources --remove https://rubygems.org//
Run the following command after the response.
$ gem sources -a http://ruby.taobao.org/
To verify that your ruby image is Taobao only, run the following command:
$ gem sources -l
The command above is successful only when the following text appears in the terminal.
: ***** Current sources *** submit
:
$ sudo gem install cocoapods
The reason for not directly running the last command is of course because of the wall.
---------------------------------------
2. Use cocoapods
Main Command: '$ pod install.
Scenario 1: Use cocoapods to import the afnetworking class library to the project. The address of the afnetworking class library on GitHub is.
Enter:
$ pod search AFNetworking
After a few seconds, you will see some information about the afnetworking class library in the terminal. For example, afnetworking supports cocoapods, so we can use cocoapods to import afnetworking to your project.
First, we need to add cocoapods support to our project. You can follow the steps in the editor to create a project named cocoapodsdemo using xcode for the following tutorial. After creation,
Before proceeding to the next step, let's take a look at the xcode directory structure of the project when the project does not support cocoapods: Wait a moment and compare it with the xcode directory structure of the project after the project supports cocoapods. You may ask why cocoapods can download afnetworking instead of other class libraries? The answer to this question is that there is a file to control what cocoapods should download. This file is called "podfile" (note that it must be the file name without a suffix ). You create a podfile file, and then add the class library you want to download in it, that is, tell cocoapods, "so-and-so, come to the bowl !". Only one podfile is required for each project. Well, let's just talk about it. Let's first create this magical podfile. Enter the directory where your project is located in the terminal (CD command), and then use Vim to create podfile in the current directory,
Run:
$ Vim podfile
Enter the following text in the podfile file:
platform :ios, ‘7.0‘pod "AFNetworking", "~> 2.0"
Note: This text is not generated by a small Editor. It can be found on the afnetworking GitHub page. The two sentences mean that the maximum version of IOS supported by afnetworking is iOS 7.0 and the afnetworking version to be downloaded is 2.0. Save and exit. In the vim environment, the SAVE and exit command is:
: WQ
At this time, you will find a file named podfile in your project directory, and the file content is what you just entered. Note that the podfile and your project file. xcodeproj should be in the same directory. At this time, you can use cocopods to download the afnetworking class library. Or in the current project directory of the terminal, run the following command:
$ Pod install
---------------------------------------
3. Make a self-made pods source (create your own podspec file)
Main commands:
Pod spec create https://github.com/iiiyu/XCAsyncTestCase
Chestnut: xcasynctestcase first, fork it to your project. (What does not fork? Then, clone the fork to the project under your account and add the CD to 1pod spec create https://github.com/iiiyu/xcasynctestcase. many projects have no tag. It is under your own. You can do this. Add a tag to the project. So that the pod can be automatically recognized. 1234567
Git tag-A 0.0.1-M "tag release 0.0.1"
Git push-tagsrm-RF xcasynctestcase. podspec
Pod spec create https://github.com/iiiyu/xcasynctestcaseok.
Open it in your favorite editor. 1 mate xcasynctestcase. podspec does not actually need to modify the content in it. I will delete the comment and change it to the original author. Then change the source code location to correct. Of course, the most important thing is S. source_files. You need to find the path of the file you want to include. Then match with the wildcard. OK. Of course, for other items, please refer to the Optional comments. Here is a five-minute Hello world. After in-depth discussion, push the modified file to GitHub for 12345.
git add XCAsyncTestCase.podspecgitcommit -am "add XCAsyncTestCase.podspec file"git push
Finally, add the address of this third-party library to the podfile of your project. Http://cocoapods.org/
pod ‘XCAsyncTestCase‘, :git => ‘https://github.com/iiiyu/XCAsyncTestCase.git‘
You can use pod install
Reference Source:
Http://code4app.com/article/cocoapods-install-usage
Http://iiiyu.com/2013/12/19/learning-ios-notes-thirty-one/
Http://cocoapods.org/
[Cocoapods Quick Production] basic usage of cocoapods and self-made podspec