一、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