cocoaPods更新问题解决

转自:http://blog.csdn.net/xingxingrainlove/article/details/53257944

今天在运行项目时突然遇到异常报错: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%)

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%)

Successfully installed claide-1.0.1

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%)

……………...

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 , Michal Papis [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 -fsSLhttps://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 --removehttps://ruby.taobao.org

https://ruby.taobao.orgremoved from sources

czhdeiMac:kuihuajingyingwang czh$gem sources -ahttp://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%)

Successfully installed i18n-0.7.0

如果这样执行 pod install的时候还出现

The dependency ``isnotusedinany concrete target

The dependency `AFNetworking`isnotusedinany concrete target

官网是这样给推荐的:

在创建Podfile的时候,用这种格式使用,

platform:ios,'8.0'

#use_frameworks!个别需要用到它,比如reactiveCocoa

target 'MyApp' do

pod'AFNetworking','~> 2.6'

pod'ORStackView','~> 3.0'

pod'SwiftyJSON','~> 2.3'

end

里面的MyApp记得替换为自己攻城里面的target。这样就基本OK了,执行pod install / pod update 就都可以了。(use_frameworks! 这个是个别需要的,这里修改一下,可以把我上面的代码中的这一行【删除】

Successfully installed claide-1.0.1

[!] Pods written in Swift can only be integrated as frameworks; add `use_frameworks!` to your Podfile

正确的写法Swift:

platform :ios, ‘8.0’

target ‘TestObjectTwo’do

pod ‘Alamofire’, ‘~>4.0’

pod ‘SnapKit’, ‘~>3.0.2’

use_frameworks!

end

在安装CocoaPods出现了以下问题:

ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)

ERROR: You must add /C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority to your local trusted store

ERROR: SSL verification error at depth 2: self signed certificate in certificate chain (19)

ERROR: Root certificate is not trusted (/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA)

出现这个问题的原因主要是Ruby环境需要2.2版本以上,所以要更新Ruby环境。

更新Ruby环境

0.首先要安装 Homebrew 终端输入这条命令即可 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

1.安装rvm $ curl -L get.rvm.io | bash -s stable

2.装载rvm $ source ~/.rvm/scripts/rvm

3.安装2.3.0版本ruby $ rvm install 2.3.0

4.将2.3.0设为默认 $ rvm use 2.3.0 --default

你可能感兴趣的:(cocoaPods更新问题解决)