iOS 最新版 CocoaPods 的安装流程
2016-04-03 本文已影响45人
九月文化
做了太多次的CocoaPods安装,每次都没有记录,这次备案一下,换新电脑可以直接用
第一步:移除现有Ruby默认数据来源源
gem sources --remove https://rubygems.org/
第二步:使用新的源,通过淘宝镜像来源
gem sources -a https://ruby.taobao.org/
第三步:验证新源是否替换成功
gem sources -l
第四步:安装CocoaPods
sudo gem install cocoapods
备注:苹果系统升级 OS X EL Capitan 后改为
sudo gem install -n /usr/local/bin cocoapods
第五步:启动一下看看有没有问题
pod setup
第六步:测试以下安装是否成功,能搜索到东西,那就没问题
pod search 第三方
可能遇到的错误
错误1:
Error fetching http://ruby.taobao.org/:
bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
解决方案:将第二步中的
gem sources -a http://ruby.taobao.org/
--- 修改为 https ---
gem sources -a https://ruby.taobao.org/
错误2:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
解决方案:将第四步中安装CocoaPods 的
原因:苹果系统升级OS X EL Capitan后会出现的插件错误
sudo gem install cocoapods
--- 修改为 ---
sudo gem install -n /usr/local/bin cocoapods
今天重新安装CocoaPods遇到一个错误
错误
Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.

查ruby版本

看看rvm命令能否使用,

不行,安装一下rvm

启动一下

rvm命令可以用了

查一下 ruby版本

安装失败

执行一个命令,卸载home-brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

重新执行一下 rvm install 2.2.2 经过几分钟终于好了
最后,在执行sudo gem install -n /usr/local/bin cocoapods