安裝 Homebrew 和 cocoapods

安裝Homebrew

一、獲取最新安裝腳本到本地編輯

1、cd ~
2、curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install

編輯 brew_install 文件

# This script installs to /usr/local only. To install elsewhere (which is
# unsupported) you can untar https://github.com/Homebrew/brew/tarball/master
# anywhere you like.
HOMEBREW_PREFIX = "/usr/local".freeze
HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze
HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze
HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze
# BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze

注釋掉 BREW_REPO = "https://github.com/Homebrew/brew".freeze
新增行 BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze

鏈接: https://pan.baidu.com/s/1icmX5BXaWUI1B1Ge7od1RA 提取碼: 5ies

二、執(zhí)行修改后的腳本安裝

1、/usr/bin/ruby ~/brew_install
會(huì)卡在 Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... 好久
2、Command + C 停止
3、cd "$(brew --repo)/Library/Taps/"
4、mkdir homebrew
5、cd homebrew
6、git clone git://mirrors.ustc.edu.cn/homebrew-core.git
7、繼續(xù)執(zhí)行 /usr/bin/ruby ~/brew_install
8、看到 Installation successful! 就安裝成功了

三、修改 Homebrew 源為國(guó)內(nèi)鏡像

替換 Homebrew 默認(rèn)源
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
替換 homebrew-core 源
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git

四、brew 更新

brew update

五、設(shè)置 bintray 鏡像

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

安裝cocoapods

1、更新ruby環(huán)境:sudo gem update --system
2、刪除ruby原有的鏡像源:$ gem sources --remove https://gems.ruby-china.org/
2、添加ruby最新的鏡像源:$ gem sources --add https://gems.ruby-china.com/
3、查看鏡像源:$ gem sources -l
確保只有 https://gems.ruby-china.com/

5、升級(jí)安裝cocoapods:sudo gem install cocoapods 或 sudo gem install -n /usr/local/bin cocoapods --pre

6、查看升級(jí)后的cocoapods版本:pod --version

7、pod setup  經(jīng)常不行,即使科學(xué)上網(wǎng)也太慢,推薦使用國(guó)內(nèi)鏡像

創(chuàng)建repo文件夾
mkdir -p ~/.cocoapods/repos/
查看當(dāng)前倉庫的信息
pod repo
顯示 0 repos則表示沒有倉庫
刪除cocoapods鏡像
pod repo remove master

pod setup 失敗太慢,使用清華大學(xué)鏡像
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/master

cocoapods搜索不到最新的第三庫,一般有可能是緩存的問題我們可以使用:
更新本地倉庫
pod repo update
從本地已有倉庫更新當(dāng)前項(xiàng)目中的第三方(不更新本地倉庫)
pod update --verbose --no-repo-update
但是有時(shí)候,更新了卻還是不行,那我們就
1.pod cache clean --all
2.rm -rf ~/Library/Caches/CocoaPods
3.pod repo update
清除所有的緩存,重新建立索引。
此時(shí)重新搜索就可以了。
最后編輯于
?著作權(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),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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