最近在用cocoapods导入第三方库的时候出现如下错误,现在将错误处理放发一步步贴出来:
1、当导入一些第三方库的时候如:
pod 'Masonry', '~> 1.0.2'
pod 'MBProgressHUD', '~> 1.0.0'
pod 'YYAsyncLayer', '~> 1.0.0'
pod 'THLabel', '~> 1.4.8'
pod 'AFNetworking', '~> 3.1.0'
pod 'TMCache', '~> 2.1.0'
pod 'JSONModel', '~> 1.5.1'
pod 'SSZipArchive', '~> 1.5.0'
1、
当你执行pod install时出现了下面的报错:
[!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
这就是说我们的cocopods版本太旧,是currently using 0.39.0这个,这个master需要CocoaPods 1.0.0 的版本
2、
那执行 sudo gem update cocoapods 更新cocopods 就又提示了下面这个错误:
Updating cocoapods
ERROR: While executing gem ... (Errno::EPERM)
3、接下来执行sudo gem install -n /usr/local/bin cocoapods --pre
就可以成功的更新了cocopods的版本,采用pod —version 查看cocopods的版本号1.0.0~1.2.0
4、接下来执行pod install 的时候,又会出现如下错误
pod install
Re-creating CocoaPods due to major version update.
Analyzing dependencies
[!] The dependency `AFNetworking (~> 3.1.0)` is not used in any concrete target.
The dependency `SDWebImage (~> 3.7.6)` is not used in any concrete target.
The dependency `UITableView+FDTemplateLayoutCell (~> 1.5.beta)` is not used in any concrete target.
The dependency `MJRefresh (~> 3.1.0)` is not used in any concrete target.
The dependency `SVProgressHUD (~> 2.0.3)` is not used in any concrete target.
The dependency `FMDB (~> 2.6.2)` is not used in any concrete target.
The dependency `MJExtension (~> 3.0.10)` is not used in any concrete target.
The dependency `RealReachability` is not used in any concrete target.
The dependency `CocoaLumberjack` is not used in any concrete target.
The dependency `GPUImage (~> 0.1.7)` is not used in any concrete target.
The dependency `TTTAttributedLabel` is not used in any concrete target.
The dependency `Masonry (~> 1.0.2)` is not used in any concrete target.
The dependency `MBProgressHUD (~> 1.0.0)` is not used in any concrete target.
The dependency `YYAsyncLayer (~> 1.0.0)` is not used in any concrete target.
The dependency `THLabel (~> 1.4.8)` is not used in any concrete target.
The dependency `TMCache (~> 2.1.0)` is not used in any concrete target.
The dependency `JSONModel (~> 1.5.1)` is not used in any concrete target.
The dependency `SSZipArchive (~> 1.5.0)` is not used in any concrete target.
The dependency `FLEX (~> 2.0)` is not used in any concrete target.
这个问题产生的可以通过 $ pod --version 查看版本号;
原因是podfile升级到最新版本,pod里的内容必须明确指出所用第三方库的target;可以修改Podfile文件的配置文件,让它兼容不指定固定版本;且又不报错;
platform:ios, '8.0'
inhibit_all_warnings!
target ‘XXXProjectName’ do
pod 'AFNetworking', '~> 3.1.0'
pod 'SDWebImage', '~> 3.7.6'
pod 'UITableView+FDTemplateLayoutCell', '~> 1.5.beta'
pod 'MJRefresh', '~> 3.1.0'
pod 'SVProgressHUD', '~> 2.0.3'
pod 'FMDB', '~> 2.6.2'
pod 'MJExtension', '~> 3.0.10'
pod 'RealReachability'
pod 'CocoaLumberjack'
pod 'GPUImage', '~> 0.1.7'
pod 'TTTAttributedLabel'
pod 'Masonry', '~> 1.0.2'
pod 'MBProgressHUD', '~> 1.0.0'
pod 'YYAsyncLayer', '~> 1.0.0'
pod 'THLabel', '~> 1.4.8'
pod 'TMCache', '~> 2.1.0'
pod 'JSONModel', '~> 1.5.1'
pod 'SSZipArchive', '~> 1.5.0'
pod 'FLEX', '~> 2.0', :configurations => ['Debug']
end
其中XXXProjectName要换成当前target名,最后不要忘记增加一个end结尾。
如果工程中有多个target要引用,可以参考下面的链接进行处理:
http://www.cnblogs.com/wujy/p/5545680.html
本文参考了 博客园 踏浪帅的博主的文章:更新Cocopods碰到的问题及知识点,上面链接就是此片博文的地址。