一、Podfile.lock文件
- PODS:
- - AFNetworking (2.1.0):
- - AFNetworking/NSURLConnection
- - AFNetworking/NSURLSession
- - AFNetworking/Reachability
- - AFNetworking/Security
- - AFNetworking/Serialization
- - AFNetworking/UIKit
- - AFNetworking/NSURLConnection (2.1.0):
- - AFNetworking/Reachability
- - AFNetworking/Security
- - AFNetworking/Serialization
- - AFNetworking/NSURLSession (2.1.0):
- - AFNetworking/NSURLConnection
- - AFNetworking/Reachability (2.1.0)
- - AFNetworking/Security (2.1.0)
- - AFNetworking/Serialization (2.1.0)
- - AFNetworking/UIKit (2.1.0):
- - AFNetworking/NSURLConnection
- - Reachability (3.0.0)
- - SBJson (4.0.0)
- DEPENDENCIES:
- - AFNetworking (~> 2.0)
- - Reachability (~> 3.0.0)
- - SBJson (~> 4.0.0)
- SPEC CHECKSUMS:
- AFNetworking: c7d7901a83f631414c7eda1737261f696101a5cd
- Reachability: 500bd76bf6cd8ff2c6fb715fc5f44ef6e4c024f2
- SBJson: f3c686806e8e36ab89e020189ac582ba26ec4220
- COCOAPODS: 0.29.0
- pod 'SBJson'
当团队中的某个人执行完pod install命令后,生成的Podfile.lock文件就记录下了当时最新Pods依赖库的版本,这时团队中的其它人check下来这份包含Podfile.lock文件的工程以后,再去执行pod install命令时,获取下来的Pods依赖库的版本就和最开始用户获取到的版本一致。如果没有Podfile.lock文件,后续所有用户执行pod install命令都会获取最新版本的SBJson,这就有可能造成同一个团队使用的依赖库版本不一致,这对团队协作来说绝对是个灾难!
- 更改Podfile,使其指向最新版本的SBJson依赖库;
- 执行pod update命令;
二、Podfile文件
1、Podfile文件存放位置
这是在上篇文章中,遗留的一个问题。通常情况下我们都推荐Podfile文件都放在工程根目录,如下图所示:
- xcodeproj "/Users/wangzz/Desktop/CocoaPodsTest/CocoaPodsTest.xcodeproj"
- platform :ios
- pod 'Reachability', '~> 3.0.0'
- pod 'SBJson', '~> 4.0.0'
- platform :ios, '7.0'
- pod 'AFNetworking', '~> 2.0'
2、Podfile和target
- link_with 'CocoaPodsTest', 'Second'
- platform :ios
- pod 'Reachability', '~> 3.0.0'
- pod 'SBJson', '~> 4.0.0'
- platform :ios, '7.0'
- pod 'AFNetworking', '~> 2.0'
- target :'CocoaPodsTest' do
- platform :ios
- pod 'Reachability', '~> 3.0.0'
- pod 'SBJson', '~> 4.0.0'
- platform :ios, '7.0'
- pod 'AFNetworking', '~> 2.0'
- end
- target :'Second' do
- pod 'OpenUDID', '~> 1.0.0'
- end
3、使用Podfile管理Pods依赖库版本
- pod 'AFNetworking' //不显式指定依赖库版本,表示每次都获取最新版本
- pod 'AFNetworking', '2.0' //只使用2.0版本
- pod 'AFNetworking', '> 2.0' //使用高于2.0的版本
- pod 'AFNetworking', '>= 2.0' //使用大于或等于2.0的版本
- pod 'AFNetworking', '< 2.0' //使用小于2.0的版本
- pod 'AFNetworking', '<= 2.0' //使用小于或等于2.0的版本
- pod 'AFNetworking', '~> 0.1.2' //使用大于等于0.1.2但小于0.2的版本
- pod 'AFNetworking', '~>0.1' //使用大于等于0.1但小于1.0的版本
- pod 'AFNetworking', '~>0' //高于0的版本,写这个限制和什么都不写是一个效果,都表示使用最新版本
三、CocoaPods常用命令
1、pod install
2、pod update
3、pod search
- $ pod search OpenUDID
- -> OpenUDID (1.0.0)
- Open source initiative for a universal and persistent UDID solution for iOS.
- pod 'OpenUDID', '~> 1.0.0'
- - Homepage: http://OpenUDID.org
- - Source: https://github.com/ylechelle/OpenUDID.git
- - Versions: 1.0.0 [master repo]
- pod 'OpenUDID', '~> 1.0.0'
4、pod setup
- $ pod setup
- Setting up CocoaPods master repo
- Updating 7cd4668..f3d3ced
- Fast-forward