1.安裝RVM ,升級Ruby環(huán)境?
(1)ruby -v //查看Ruby版本號
(2)安裝RVM
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
(3)查看rvm版本號
rvm -v?
顯示如下
rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
(4)列出ruby可安裝的版本信息
rvm list known
顯示如下

(5)安裝一個ruby版本(這里我選擇的是2.4.1版本,當然你也可以選擇其他的
rvm install 2.4.1

(6)設置為默認版本
rvm use 2.4.1 --default
2.更換源(以前的taobao Gems源【https://ruby.taobao.org】已停止維護 ,用https://gems.ruby-china.org/)
(1)sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.org/
(2)查看源
gem sources -l
如下:
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
3.開始安裝
(1)sudo gem install -n /usr/local/bin cocoapods
(2)如果安裝了多個Xcode使用下面的命令選擇(一般需要選擇最近的Xcode版本)
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
(3)安裝本地庫
pod setup
完成后應該如下
Setting up CocoaPods master repo
? $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
? Cloning into 'master'...
? remote: Counting objects: 1879515, done.? ? ? ?
? remote: Compressing objects: 100% (321/321), done.? ? ? ?
? Receiving objects:? 21% (404525/1879515), 73.70 MiB | 22.00 KiB/
然后就是漫長的等待,當然,網(wǎng)絡好的情況下會更快
執(zhí)行pod setup錯誤提示:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 2278904, done.? ? ? ?
remote: Compressing objects: 100% (503/503), done.? ? ? ?
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解決方法
<1>
git?config?--global?http.postBuffer?524288000
git?config?--list //查看列表
<2> 執(zhí)行Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master和pod setup效果一樣,之后在更新。成功率會提高哦
<3>如果一直慢的要死,,,卡的要死,,,網(wǎng)絡不給力。。。。直接下載替換吧。。。。。。。。
鏈接: https://pan.baidu.com/s/1wriINtoLn3LI4Ik_a9NFVg 密碼: 8qdq
<4>2021.1.22改,
可直接傳到git再克隆到~/.cocoapods/repos/master
(https://gitee.com/wangtongmin/specs.git)
~/.cocoapods/repos/master去到這個目錄直接替換,,,,簡單粗暴吧。。。哈哈哈!??!