Document directory
- Search
- Initialization
- Add a Library:
- Header file path
- Other third-party libraries.
Introduction:
Third-party libraries are indispensable during application development, which can improve the development efficiency. Some frequently used libraries are used in new projects. You have to manually Add them to the Project and use multiple libraries, which makes it inconvenient to manage them. CocoaPods can help you manage third-party libraries in Xcode.
How can this problem be used? Install CocoaPods first.
1. CocoaPods is a software running in Ruby. It may take several minutes to install it. The installation name is as follows:
Sudo gem install cocoapods
2. If you want to generate a document for each third-party library, run
Brew install appledoc is optional.
After the installation is complete, the following message is displayed:
If your Ruby environment is not new enough, you may need to update it:
Gem update -- system
How can I use the pod after it is installed? Search
First try the search function. You can use the pod to search for the library you need, for example, the JSONKit Library:
Pod search is the name of the search, followed by the name of the database.
Pod search JSONKit
Search:
Initialization
Okay. In the terminal shell, cd comes to the project you want to manage and run: pod install
After running, you will find that your project directory is like this:
*. Xcworkspace pod and other files are added. This is the project management file generated by the pod. Open the LibDemo. xcworkspace project file and see the following directory structure in Xcode:
Add a Library:
Vim Podfile open the file and add the JSONkit you just searched to it.
Platform: ios
Pod 'jsonkit'
Save and exit.
Run: pod update
In this way, the JSONKit library is downloaded and associated with the local project. This is why Xcode prompts you to update the project.
Click Revert.
At this time, you can see that the pod part of the project is added with the JSONKit library. Well, the third-party library is so magical.
Header file path
Try using JONSKit. h and reference it in ViewController. m. What should I do if I cannot find the header file? The Directory of the header file has not been set. Set it in the Target of the project:
As shown in, select recursive after $ {SRCROOT.
In the reference header file:
Perfect.
Other third-party libraries.
After the Podfile file is added, it will be OK under pod update.
platform :ios, '5.0'pod 'JSONKit'pod 'AFNetworking'pod 'MBProgressHUD'pod 'Reachability'pod 'Nimbus/Core'
For example, if I reference the above libraries, Nimbus is too large. I only need Core and can write it like this.
CocoaPods also has many advanced functions that can be used as needed.
Reference: https://github.com/CocoaPods/CocoaPods/wiki
Rong Fangzhi (http://blog.csdn.net/totogo2010)
This article follows the "signature-non-commercial use-consistency" creation public agreement