安装cocoapods遇到两大坑-Ruby版本升级和Podfile的配置

今天安装cocoapods

#移除原有ruby源
$ gem sources --remove https://rubygems.org/
#使用可用的淘宝网
$ gem sources -a https://ruby.taobao.org/
#检查仅且只有一个ruby源
$ gem sources -l
#安装cocoapods
$ sudo gem install cocoapods

报错了:

是说Ruby版本过低,必须高于2.2.2.版本。所以

#查看自己电脑上的Ruby版本
$ ruby -v

是2.0.0.版本的,搜了一下需要升级Ruby。得益于http://blog.csdn.net/lissdy/article/details/9191351

#安装RVM
$ curl -L get.rvm.io | bash -s stable
#检测安装是否正常
$ rvm -v
#查看当前ruby版本  
$ ruby -v  
#列出已知的ruby版本  
$ rvm list known  
#安装ruby 2.3
$ rvm install 2.3  
#查看当前ruby版本  
$ ruby -v  

然而我安装时出现了下面这种鬼东西,反正不是什么正常信息

搞了大半小时还是这样,还多了一个错误!!!神奇的是还能安装成功。。。。。。

之后就可以正常安装cocoapods了。

#安装 CocoaPods
$ sudo gem install cocoapods
$ pod setup

But 成功之后使用cocoapods导入第三方出错:

Re-creating CocoaPods due to major version update.
Analyzing dependencies
[!] The dependency `AFNetworking (~> 3.0)` is not used in any concrete target.
The dependency `MBProgressHUD (~> 0.9.2)` is not used in any concrete target.
The dependency `MJRefresh` is not used in any concrete target.
The dependency `SDWebImage (~> 3.0)` is not used in any concrete target.
The dependency `Masonry` is not used in any concrete target.
The dependency `SVProgressHUD` is not used in any concrete target.
The dependency `JSONModel` is not used in any concrete target.
The dependency `CTAssetsPickerController (~> 3.3.2-alpha)` is not used in any concrete target.

原因是我安装的cocoapods版本是  1.1.0.beta.1,所以podfile升级到最新版本后配置文件里面的内容必须明确所依赖的第三方的target

像上面这样直接修改podfile的内容格式之后 pod install耐心等待就可以导入你想要的第三方

原文地址:https://www.cnblogs.com/xs514521/p/5664097.html