cocoaPods更新問題解決

轉(zhuǎn)自:http://blog.csdn.net/xingxingrainlove/article/details/53257944

今天在運行項目時突然遇到異常報錯:not find -lpod;一開始感覺很莫名其妙,隨后意識到可能是cocoaPods的問題,于是嘗試更新pod install,結(jié)果紅色警告提示:

The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0);所以最終問題是cocoaPods版本太低,需要更新了(我的當(dāng)前版本是0.39.0)。

《自以為是的更新步驟:

1.更新gem

$ sudo gem update

結(jié)果如下:

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更新失敗了,出現(xiàn)了錯誤,究其原因就是Ruby version的版本較低導(dǎo)致。

注:這種情況是不正常的,說明更新失敗,其它可以忽略:失敗原因就在畫線的兩行ERROR里面。

2.我自動忽略了以上報錯繼續(xù)進行下面的操作:

gem sources -l

sudo gem install cocoapods

很顯然注定是要失敗的,一直報錯:

ERROR:? While executing gem ... (Errno::EPERM)

Operation not permitted - /usr/bin/xcodeproj

最后一步pod setup

繼續(xù)報錯:[!] The `master` repo requires CocoaPods 1.0.0 -? (currently using 0.39.0)

所以什么用也沒有!!!!!

《正確的解決步驟

從網(wǎng)上搜索解決方案,經(jīng)過實踐總結(jié)正確的步驟。(幫助文章鏈接:http://blog.csdn.net/yangyangzhang1990/article/details/52252146

很明顯從上面的問題中找到了最根本的原因是Ruby的版本較低。

第一步:首先檢測各種版本是否合格:

rvm-v ?:ram相當(dāng)于一個ruby倉庫,管理ruby不同版本。(我的當(dāng)前版本是1.26.11,可以,當(dāng)然最好更新到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:看一下當(dāng)前版本

安裝成功提示是: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)"

詳細(xì)安裝 步驟 可查看博客地址:http://blog.csdn.net/yangyangzhang1990/article/details/51578565

第四步:安裝cocoaPods

安裝home-brew 成功后,執(zhí)行? 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查看當(dāng)前最新的鏡像源地址

具體操作提示:

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

如果這樣執(zhí)行 pod install的時候還出現(xiàn)

The dependency ``isnotusedinany concrete target

The dependency `AFNetworking`isnotusedinany concrete target

官網(wǎng)是這樣給推薦的:

在創(chuàng)建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了,執(zhí)行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出現(xiàn)了以下問題:

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)

出現(xiàn)這個問題的原因主要是Ruby環(huán)境需要2.2版本以上,所以要更新Ruby環(huán)境。

更新Ruby環(huán)境

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設(shè)為默認(rèn) $ rvm use 2.3.0 --default

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容