cocoapod安裝 Homebrew方式 適合國人成功率高速度快(30分鐘通關(guān))

cocoapod安裝(Homebrew)

Homebrew安裝

第一步:安裝Homebrew

使用國內(nèi)腳本-打開terminal輸入以下命令

安裝腳本(終端中粘貼下方命令回車)

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

卸載腳本:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"


第二步:替換ruby源

檢測ruby源:

?gem sources -l?

正常我們看到的是這樣:

*** CURRENT SOURCES ***

https://rubygems.org/


移除自帶的源:

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

替換成國內(nèi)源:

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

檢測是否替換成功:gem sources -l?

顯示:

*** CURRENT SOURCES ***

https://gems.ruby-china.com/

第三步:安裝cocoapod

使用Homebrew安裝CocoaPods :

brew install cocoapods

?安裝完成之后:

?pod setup

查詢當(dāng)前Pod版本與安裝版本是否一致:

brew info cocoapods

pod --version

修復(fù)版本不一致的問題:

brew link --overwrite cocoapods

下載cocoapod索引文件到本地(這里使用一定要國內(nèi)地址下載):

git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/master

pod官方源地址可能下載不下來(需要黑魔法):

git clone?https://github.com/CocoaPods/Specs.git ?~/.cocoapods/repos/master

如果使用官方源也可以使用 :

pod repo update --verbose

第四步:檢測是否安裝成功

pod search AFNetworking

如果出現(xiàn)

# [!] Unable to find a pod with name, author, summary, or description matching AFNetworking

可以進(jìn)入 ~/Library/Caches/CocoaPods文件夾尋找并刪除search_index.json,然后重新執(zhí)行

pod search AFNetworking


如果出現(xiàn)安裝完成還是提示找不到brew和pod

command not found:brew

command not found:pod

原因是因為換成國內(nèi)的源后默認(rèn)路徑找不到,我們需要配置路徑

使用終端打開.zshrc 或者.bash_profile

open ~/.zshrc

.zshrc中加上下面這段

#intel -- intel芯片

export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

#apple-- intel芯片

export PATH="/usr/local/bin:/opt/homebrew/sbin:$PATH"

再運(yùn)行

source?~/.zshrc?

就可以了

常見的源:

source?'https://github.com/CocoaPods/Specs.git'?

source?'https://cdn.cocoapods.org/'?

source'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

最后編輯于
?著作權(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)容