更新Mac系統(tǒng)后 cocoapods升級(jí)問題 2020-04-23

正文

由于需要最新版本的Xcode工具,就升級(jí)了電腦系統(tǒng)到10.15.4 (19E287)。安裝了最新Xcode11.4安裝后發(fā)現(xiàn) cocoapods使用出現(xiàn)異常。需要重新安裝cocoapods.

安裝

因?yàn)镸ac電腦自帶Ruby環(huán)境,我們就只需打開終端直接安裝就可以了。如果出現(xiàn)ruby版本過低的情況可以先更新ruby。

1.查看當(dāng)前ruby版本

ruby -v

2.升級(jí)ruby環(huán)境(升級(jí)ruby需要借助rvm,需要先安裝rvm)

1.curl -L  https://get.rvm.io | bash -s stable
2.source ~/.rvm/scripts/rvm
3.rvm -v

如果要升級(jí)rvm使用命令

rvm get stable

3.安裝ruby

1.rvm list known

結(jié)果為

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.6]
[ruby-]2.5[.5]
[ruby-]2.6[.3]
[ruby-]2.7[.0-preview1]
ruby-head

此時(shí)可以根據(jù)自己的需要安裝指定版本的ruby。

rvm install 2.6.3

本文相關(guān)操作是在ruby[ruby-]2.6[.3]完成的。

4.更換鏡像源(如果已經(jīng)處理可忽略此步驟)

sudo gem update --system

gem sources --remove https://rubygems.org/

gem sources --add https://gems.ruby-china.com/

查看更換結(jié)果

gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com

5.安裝cocoapods 10.11后命令 之前的命令為(sudo gem install cocoapods)

sudo gem install -n /usr/local/bin cocoapods

此時(shí)如果出現(xiàn)以下錯(cuò)誤,原因是因?yàn)樵诎惭bxcode的時(shí)候保留了之前的版本,當(dāng)前系統(tǒng)上有兩個(gè)版本的xcode.

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Users/gigaiot-sasai/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/Users/gigaiot-sasai/.rvm/rubies/ruby-2.6.3/bin/ruby -I /Users/gigaiot-sasai/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200423-788-10f5isy.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

處理步驟
5.1 把最近安裝的xocde拖到中,注意名稱要為xcode默認(rèn)名。


image.png

5.2 終端執(zhí)行命令

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

5.3 再次執(zhí)行安裝命令

sudo gem install -n /usr/local/bin cocoapods

安裝中...

Building native extensions. This could take a while...
Successfully installed ffi-1.12.2
Successfully installed ethon-0.12.0
Successfully installed typhoeus-1.3.1
Successfully installed cocoapods-core-1.9.1
Successfully installed xcodeproj-1.16.0
Successfully installed cocoapods-1.9.1
Parsing documentation for ffi-1.12.2
Installing ri documentation for ffi-1.12.2
Parsing documentation for ethon-0.12.0
Installing ri documentation for ethon-0.12.0
Parsing documentation for typhoeus-1.3.1
...

此時(shí)等待命令執(zhí)行完畢就可以了。

完成后搜索測(cè)試出現(xiàn)以下錯(cuò)誤。


image.png

終端執(zhí)行命令 即可

pod repo remove trunk
image.png

此時(shí)就可以正常搜索查詢檢索了。

總結(jié):

1.本文的場(chǎng)景是升級(jí)mac系統(tǒng).
2.安裝并保留了多個(gè)xcode.
3.pod search xx 命令長時(shí)間卡住沒有正確返回.

卸載cocopods 傳送門

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容