Original URL: http://blog.csdn.net/totogo2010/article/details/8198694
Introduced:
Third-party libraries are indispensable when developing applications and can improve the efficiency of development. Some frequently used libraries, in the new project with IS, you have to manually add to the project, with the library more up, it is not easy to manage. Discover cocoapods This software, can help you to manage the third party's library in Xcode, very convenient.
How does that work? Install Cocoapods first.
1, Cocoapods is running in Ruby software, installation may take a few minutes, installation named:
sudo gem install Cocoapods
2. If you want to generate a document for each third-party library, run
Brew Install Appledoc This step is optional.
Prompt when installation is complete:
If your ruby environment is not new, you might want to update it:
Gem Update--system
Now pod is installed, how to use it? Search
First try the search function, what library you need, you can use the pod to search, such as to use Jsonkit this library:
The pod search is named after the name of the library.
Pod Search Jsonkit
Search out:
Initialization
Okay, in the terminal shell CD comes to the project you want to manage, run: Pod install
When you're done, you'll find something like this in your project directory:
More *.xcworkspace pods and other files. This is the project management file that pod generates, open the Libdemo.xcworkspace project file, and see in Xcode the directory structure:
Add a library:
Vim Podfile Open the file and add the jsonkit you just searched for.
Platform:ios
Pod ' Jsonkit '
Save exit.
Run: Pod update
This is to download the Jsonkit library and associate it with the local project, which is Xcode prompting you to update the project
Point revert.
At this point you look at the pod section of the project, more Jsonkit library. Well, third-party libraries are so magical to add in.
Header file path
Then try using JONSKit.h, quoted in the VIEWCONTROLLER.M. Can not find the head file, how to do? Do not set the header file directory, set the target in the project:
As shown, select recursive after entering ${srcroot}.
In the reference header file:
Perfect.
Other third-party libraries.
The Podfile file is added after pod update is OK.
[HTML]View PlainCopy
- Platform:ios, ' 5.0 '
- Pod ' Jsonkit '
- Pod ' afnetworking '
- Pod ' Mbprogresshud '
- Pod ' reachability '
- Pod ' Nimbus/core '
For example, I quoted the above library, Nimbus is too big, I only need the Core, also can write.
Cocoapods also has a lot of advanced features that can be used on demand.
Reference: Https://github.com/CocoaPods/CocoaPods/wiki
Jongfangzhi (http://blog.csdn.net/totogo2010)
This article follows "Attribution-non-commercial use-consistent" authoring public agreement
"Turn" cocoapods a management tool for objective-c third-party libraries