Cocopods 使用技巧
-
首先其中一个资源库本地的最新版本查询
pod search SDWebImage 结果为 -> SDWebImage (4.0.0-beta2) Asynchronous image downloader with cache support with an UIImageView category. pod 'SDWebImage', '~> 4.0.0-beta2' - Homepage: https://github.com/rs/SDWebImage - Source: https://github.com/rs/SDWebImage.git - Versions: 4.0.0-beta2, 4.0.0-beta, 3.8.2, 3.8.1, 3.8.0, 3.7.6, 3.7.5, 3.7.4, 3.7.3, 3.7.2, 3.7.1, 3.7.0, 3.6, 3.5.4, 3.5.2, 3.5.1, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.7.4, 2.7, 2.6, 2.5, 2.4 [master repo] - Subspecs: - SDWebImage/Core (4.0.0-beta2) - SDWebImage/MapKit (4.0.0-beta2) - SDWebImage/GIF (4.0.0-beta2) - SDWebImage/WebP (4.0.0-beta2) -> SDWebImage+ExtensionSupport (3.7.1.2) 等等 一直到所有的版本信息 网上最新的版本 例如:https://github.com/rs/SDWebImage 直接点击releases即可查到最新版本
-
如果需要更新一个库文件
例如:把AFNetworking 从3.0.0升级到3.1.0版本 当你更改Podfile文件里的内容后,pod install 出现下面问题 ***** [!] Unable to satisfy the following requirements: - `AliyunOSSiOS (~> 2.8.0)` required by `Podfile` None of your spec sources contain a spec satisfying the dependency: `AliyunOSSiOS (~> 2.8.0)`. You have either: * out-of-date source repos which you can update with `pod repo update`. * mistyped the name or version. * not added the source repo that hosts the Podspec to your Podfile. Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default. ***** 此时有可能是因为本地没有记录这个库的最新跟新的版本记录,你如果查询这个库的最新版本信息会发现,最新版本就是你现在用的版本而不是你想更新的版本。 所以此时你需要更新本地的文件。 pod repo update 这个命令会更新所有的Cocopods管理的资源的本地记录,将会非常的慢 所以优先考虑方式是制定更新这个库 pod repo update /Users/<user>/.cocoapods/repos/master/Specs/<lib name> 其中<user>为你的电脑当前登陆的账户,<lib name>为这个资源所在文件路径 cd /Users/zsk/.cocoapods/repos/master/Specs/ open . 然后在当前目录中搜索AFNetworking 最后的结果是/Users/zsk/.cocoapods/repos/master/Specs/a/7/5/AFNetworking 然后pod repo update /Users/zsk/.cocoapods/repos/master/Specs/a/7/5/AFNetworking 等待完成即可。 参考资料 http://www.qingpingshan.com/rjbc/ios/167583.html
-
当你使用Cocopods管理第三方库时,如果你想移除某个库此时要注意
由于pod install的时候,如果是第一次添加,则会添加相应配置在工程中,如果是删除,之前添加的配置并不会减少。所以你需要特殊处理。由于我的工程在上传到bitbucket上时,上传的仅仅是工程文件,pod相关忽略处理,因此我的文件相对干净,但是一些配置文件在工程中设置,所以需要特殊处理 在download新的文件下来后,首先打开工程,在TARGETS-> Build Setting 下 去除Linking ->other linker flags(双击这一栏弹出的框中) 下所有的添加只留$(inherited) 其次在Search paths-> library search paths 下做同上操作
-
pod 导入资源后,在使用的时候,Xcode不会联想提示
- 选择target -> BuildSettings -> search Paths -> User Header Search Paths
- 双击User Header Search Paths这一行后面的空白区域
- 在弹出的界面中,点击+号并输入:$(PODS_ROOT),选择:recursive(会在相应的目录递归搜索文件)
- 添加第三方库头文件时自动联想
网友评论