今天在运行项目时突然遇到异常报错:not find -lpod;一开始感觉很莫名其妙,随后意识到可能是cocoaPods的问题,于是尝试更新pod install,结果红色警告提示:
The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0);所以最终问题是cocoaPods版本太低,需要更新了(我的当前版本是0.39.0)。
《自以为是的更新步骤:
1.更新gem
$ sudo gem update
结果如下:
Updating installed gems
Updating CFPropertyList
Fetching: CFPropertyList-2.3.3.gem (100%)
Successfully installed CFPropertyList-2.3.3
Parsing documentation for CFPropertyList-2.3.3
Installing ri documentation for CFPropertyList-2.3.3
Installing darkfish documentation for CFPropertyList-2.3.3
Parsing documentation for CFPropertyList-2.3.3
Updating activesupport
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: activesupport-5.0.0.1.gem (100%)
Fetching: CFPropertyList-2.3.3.gem (100%)
Successfully installed CFPropertyList-2.3.3
Parsing documentation for CFPropertyList-2.3.3
Installing ri documentation for CFPropertyList-2.3.3
Installing darkfish documentation for CFPropertyList-2.3.3
Parsing documentation for CFPropertyList-2.3.3
Updating activesupport
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: activesupport-5.0.0.1.gem (100%)
ERROR: Error installing activesupport:
activesupport requires Ruby version >= 2.2.2.//
Ruby version的版本较低, 最低需要2.2.2版本
Updating bigdecimal
Fetching: bigdecimal-1.2.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.2.7
Parsing documentation for bigdecimal-1.2.7
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/bigdecimal-1.2.7/bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.o, skipping
Installing ri documentation for bigdecimal-1.2.7
Installing darkfish documentation for bigdecimal-1.2.7
Parsing documentation for bigdecimal-1.2.7
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/bigdecimal-1.2.7/bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.o, skipping
Updating claide
Fetching: claide-1.0.1.gem (100%)
Fetching: bigdecimal-1.2.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.2.7
Parsing documentation for bigdecimal-1.2.7
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/bigdecimal-1.2.7/bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.o, skipping
Installing ri documentation for bigdecimal-1.2.7
Installing darkfish documentation for bigdecimal-1.2.7
Parsing documentation for bigdecimal-1.2.7
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/bigdecimal-1.2.7/bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.bundle, skipping
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for bigdecimal.o, skipping
Updating claide
Fetching: claide-1.0.1.gem (100%)
Successfully installed claide-1.0.1
……………...
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj//意思是gem更新失败了,出现了错误,究其原因就是
Ruby version的版本较低导致
。
注:这种情况是不正常的,说明更新失败,其它可以忽略:失败原因就在画线的两行ERROR里面。
2.我自动忽略了以上报错继续进行下面的操作:
gem sources -l
sudo gem install cocoapods
很显然注定是要失败的,一直报错:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
最后一步
pod setup
继续报错:
[!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
所以什么用也没有!!!!!
《正确的解决步骤
从网上搜索解决方案,经过实践总结正确的步骤。(帮助文章链接:
http://blog.csdn.net/yangyangzhang1990/article/details/52252146)
很明显从上面的问题中找到了最根本的原因是
Ruby的版本较低。
第一步:首先检测各种版本是否合格:
rvm -
v :ram相当于一个ruby仓库,管理ruby不同版本。(我的当前版本是
1.26.11,可以,当然最好更新到1.27.0
)
如果低于1.26.11需要安装一下:source ~/.rvm/scripts/rvm
安装成功提示是:
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
版本为:
1.27.0
第二步:将Ruby的版本升级到2.2.2,(
建议不要安装 最新版的 2.3.0)
rvm install ruby 2.2.2
安装成功提示是:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
我的提示是:
Warning, new version of rvm available '1.27.0', you are using older version '1.26.11'.j警告
版本低于最新版,暂时不影响。
ruby -v:看一下当前版本
安装成功提示是:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin15]
如果还没有安装成功,提示你 home-brew 没有安装,那你需要安装home-brew
第三步:安装home-brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
详细安装 步骤 可查看博客地址:http://blog.csdn.net/yangyangzhang1990/article/details/51578565
第四步:安装cocoaPods
安装home-brew 成功后,执行 brew install ruby 2.2.2 。
首先 ruby -v 查看你的ruby 版本
接着 rvm -v 查看你的rvm 版本
接着 gem-v 查看你的gem版本
接着 brew -v 查看你的brew 版本
gem source -l查看你的镜像源。这里推荐使用 腾讯云 镜像。
gem sources --remove 老得镜像源地址
gem sources -a 新的镜像源地址
gem sources -l 查看当前最新的镜像源地址
具体操作提示:
czhdeiMac:kuihuajingyingwang czh$ gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org
https://ruby.taobao.org/
czhdeiMac:kuihuajingyingwang czh$ gem sources --remove https://ruby.taobao.org
https://ruby.taobao.org removed from sources
czhdeiMac:kuihuajingyingwang czh$ gem sources -a http://gems.ruby-china.org/
*** CURRENT SOURCES ***
https://ruby.taobao.org
https://ruby.taobao.org/
czhdeiMac:kuihuajingyingwang czh$ gem sources --remove https://ruby.taobao.org
https://ruby.taobao.org removed from sources
czhdeiMac:kuihuajingyingwang czh$ gem sources -a http://gems.ruby-china.org/
http://gems.ruby-china.org/ added to sources
czhdeiMac:kuihuajingyingwang czh$
sudo gem install -n /usr/local/bin cocoa pods
//这个地方不能用之前旧的更新方法:
sudo gem install cocoapods
Password:
Fetching: i18n-0.7.0.gem (100%)
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
最后出现:
Sending stats
- AFNetworking, 3.1.0
- Bugtags, 2.0.1
- MBProgressHUD, 0.9.2
- Reachability, 3.2
- SDWebImage, 3.8.2
- AFNetworking, 3.1.0
- Bugtags, 2.0.1
- MBProgressHUD, 0.9.2
- Reachability, 3.2
- SDWebImage, 3.8.2
-> Pod installation complete! There are 5 dependencies from the Podfile and 5 total pods installed.
即表示安装成功
此操作完成后安装就结束了。。很惆怅的更新!!