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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,457评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,837评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,696评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,183评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,057评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,105评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,520评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,211评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,482评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,574评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,353评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,897评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,489评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,683评论 2 335

推荐阅读更多精彩内容