打開(kāi)終端添加以下命令
首先先查看源地址是否可用逻住,這邊是用的ruby-china源是可以的娇掏。
gem sources -l // 查看源列表
gem sources -remove https://ruby.taobao.org/ // 將不需要的源移除掉
gem sources -a http://gems.ruby-china.org/ // 添加ruby-china源源(當(dāng)然你有其他可用的源也可以)
sudo gem install cocoapods // 安裝cocoapods
輸入完之后可能需要輸入用戶密碼,輸入密碼后按回車即可志珍。
Password:
剩下的就是下載了译荞,可能需要等待許久時(shí)間壁涎,正常情況會(huì)出現(xiàn)類似命令
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: cocoapods-core-1.0.0.beta.8.gem (100%)
Successfully installed cocoapods-core-1.0.0.beta.8
Fetching: claide-1.0.0.beta.3.gem (100%)
Successfully installed claide-1.0.0.beta.3
Fetching: cocoapods-deintegrate-1.0.0.beta.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.0.beta.1
Fetching: cocoapods-downloader-1.0.0.beta.3.gem (100%)
如果最后出現(xiàn)類似绍妨,則說(shuō)明環(huán)境安裝成功盅抚,接下來(lái)就可以使用CocoaPods來(lái)做自己想做的事情了漠魏。
Successfully installed cocoapods-1.4.0
Parsing documentation for cocoapods-1.4.0
Done installing documentation for cocoapods after 3 seconds
1 gem installed
可能你安裝過(guò)程中也會(huì)出現(xiàn)問(wèn)題:
1.源的問(wèn)題
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
則需要替換源 http://gems.ruby-china.org/ 、https://ruby.taobao.org/
- 如果安裝或更新版本出現(xiàn)以下問(wèn)題
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
則需要使用以下命令安裝
sudo gem install -n /usr/local/bin cocoapods
下邊給出安裝時(shí)候碰到的其他問(wèn)題鏈接:https://stackoverflow.com/questions/32810808/can-not-perform-pod-install-under-el-capitan-15a279b
環(huán)境更新與安裝時(shí)候步驟類似妄均,不過(guò)不懂請(qǐng)點(diǎn)這里柱锹。
如果還碰到什么問(wèn)題,可以留言丰包。