Cocoapods is an excellent iOS package management tool for managing third-party components, perfect for third-party library updates, inter-dependency relationships, and more. Refer to the Cocoapods home page.
Installation
It is more convenient to change the source in the country.
//会被墙掉。 --remove https://rubygems.org/ -a http://ruby.taobao.org/ -l
After the installation is complete, the output information:
Fromon
Then, open the project in the future and use Xcworkspace directly, not the previous xcodeproj file.
Podfile
Under the current project, there should be a podfile:
‘7.0‘// 有时候这句很重要.‘JSONKit‘‘AFNetworking‘Alamofire‘// 这需要iOS 8.0以上,因为是swift的.// 对swift的支持.
This file contains the third-party class libraries and their dependencies that are managed using Cocoapods in the current project.
Command
- The automated installation configuration of these class libraries is performed by performing pod install.
Pod install will generate workspace, contains swiftweatherpods and pods two directories, and Pods directory contains afnetworking files, the framework is compiled into. a file, You can then refer to the. a file.
- For newly added class libraries, you can update the changes using Pod upate. Sometimes slow execution is due to upgrading Cocoapods's spec repository.
- Use the pod search name to view a third-party class library,
- The Import class library is still the same:
#import Alamofire
For ease of use, you can add the Cocoapods command alias to the system:
alias podinstall=‘pod--no-repo-update ’ alias podupdate=‘pod--no-repo-update ’
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use Cocoapods to manage third-party libraries in iOS projects