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.0Podfile.lock文件最大得用处在于多人开发。对于没有在Podfile中指定Pods依赖库版本的写法,如下:
pod 'SBJson'该句话用于获取当前SBJson这个Pods依赖库的最新版本。
这是在上篇文章中,遗留的一个问题。通常情况下我们都推荐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'指定路径使用的是xcodeproj关键字。
link_with 'CocoaPodsTest', 'Second' platform :ios pod 'Reachability', '~> 3.0.0' pod 'SBJson', '~> 4.0.0' platform :ios, '7.0' pod 'AFNetworking', '~> 2.0'这种写法就实现了CocoaPodsTest和Second两个target共用相同的Pods依赖库。
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
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的版本,写这个限制和什么都不写是一个效果,都表示使用最新版本
$ pod search OpenUDID后面的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]这里我们搜到了一条可用数据,里面描述了OpenUDID库的简要信息。其实我们真正需要的是上述结果中的第三行:
pod 'OpenUDID', '~> 1.0.0'不难看出,这是我们需要添加到Podfile文件中的。
$ pod setup
Setting up CocoaPods master repo Updating 7cd4668..f3d3ced Fast-forward接下来还会打印很多更新信息。