安裝CocoaPods

如果是新電腦,首選配置下環(huán)境

先安裝 [Xcode](http://developer.apple.com/xcode/) 開發(fā)工具,它將幫你安裝好 Unix 環(huán)境需要的開發(fā)包

然后安裝 [Homebrew](http://brew.sh)

安裝CocoaPods需要Ruby環(huán)境,所以,首先要檢查Ruby環(huán)境的版本!

1.?首先要檢查Mac是否安裝了rvm。打開終端,輸入指令rvm -v

2.安裝,終端? ? curl -L get.rvm.io | bash -s stable

***可能會提示Failed to connect to raw.githubusercontent.com port 443: Connection refused

大概率是某種網(wǎng)絡(luò)環(huán)境的問題

查詢真實IP

https://www.ipaddress.com/查詢raw.githubusercontent.com的真實IP。

修改hosts

sudo vim/etc/hosts

添加如下內(nèi)容:

199.232.28.133raw.githubusercontent.com

安裝完,退出終端,再輸入rvm -v (終端不退出,一直顯示第一步那個狀態(tài))

3.列出所有指定源里的ruby版本 ? ?rvm list known

4.安裝最新的? rvm install 2.4.0

安裝的過程中我發(fā)現(xiàn)還安裝了 homebrew(不知道的可以自己研究下)

安裝完會給提示


5.檢查下安裝的版本 rvm list

6.檢查ruby源 ?gem sources -l

7.8在一次實際安裝中,因為404的原因已經(jīng)省略掉了,實踐可行。

7.移除ruby源? gem sources --remove https://rubygems.org/

8.然后在添加? gem sources --add https://gems.ruby-china.com


9.在檢查下

10.安裝cocoapods , sudo gem install -n /usr/local/bin cocoapods

11.一般安裝完,出現(xiàn)gems installed意味著你成功了,可是我出現(xiàn)了一個問題

百度了下,大概是版本過低的問題

終端輸入sudo gem install -n /usr/local/bin cocoapods

執(zhí)行結(jié)束

再次使用pod,會執(zhí)行很久的安裝,安裝時間看網(wǎng)速了


在某次安裝中,這個地方出現(xiàn)了一個問題

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

Cloning into 'master'...

remote: Counting objects: 2140393, done.? ? ? ?

remote: Compressing objects: 100% (336/336), done.? ? ? ?

error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

fatal: The remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed

執(zhí)行下面代碼搞定:

$ git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master

12.可是我又碰到一個問題

這個問題的解決參考:

1, pod repo remove master

2, cd ~/.cocoapods/repos

3, git clone --depth 1 https://github.com/CocoaPods/Specs.git master

4, rm ~/Library/Caches/CocoaPods/search_index.json

5, pod search afnetworking

原理解釋:http://www.itdecent.cn/p/dbfdece084d5


13.LoadError - cannot load such file -- openssl報錯

?rvm安裝ruby的時候,如果出現(xiàn)這個問題,需要指定路徑

1.rvm pkg install openssl

2.rvm reinstall ruby-2.7.2 --with-openssl-dir=$rvm_path/usr

3.如果重新打開終端執(zhí)行pod --version 會報-bash: pod: command not found ,這個時候需要切換系統(tǒng)默認ruby版本

3.1.rvm list ?列出當(dāng)前系統(tǒng)中的ruby版本

3.2.rvm use 2.2.6 --default 指定系統(tǒng)默認的ruby版本

14.使用RVM安裝ruby過程中出現(xiàn)

Checking requirements for osx.

Installing requirements for osx.

Updating system.......

需要先運行下面命令,再安裝:

rvm autolibs read-only

文章參考鏈接:

1.http://www.itdecent.cn/p/96f126ef67ce

2.https://www.cnblogs.com/qiangxia/p/5668994.html

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

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

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