更換源
sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
查看更換源結(jié)果
gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
需要注意
rvm -v
和ruby -v
的版本
安裝 cocoapods
sudo gem install cocoapods
安裝成功
如果終端出現(xiàn)上面的提示,表示安裝成功。到這里還剩最后一步叮盘,還需執(zhí)行命令:
pod setup
image.png
1、更改終端的配置,找到終端簡介,勾選Rosetta
找到終端
勾選Rosetta
2霉咨、創(chuàng)建文件夾.cocoapods
和repos
,創(chuàng)建.cocoapods
時,需要打開顯示隱藏文件夾cms+shift+.
快捷鍵拍屑,然后創(chuàng)建途戒。
創(chuàng)建文件夾
3、設置repos
文件夾Git初始化僵驰,即喷斋,在repos
文件路徑下
pod repo remove master
cd ~/.cocoapods/repos
git init
git clone --depth 1 https://github.com/CocoaPods/Specs.git master
rm ~/Library/Caches/CocoaPods/search_index.json
pod search AFNetWorking
問題總結(jié)
1唁毒、pod search AFNetworking 報錯
~ % pod search AFNetworking
Setup completed
[!] Unable to find a pod with name, author, summary, or description matching `AFNetworking`
image.png
1、解決問題
創(chuàng)建一個cocoa pods 的項目
使用 cocoa pods 的項目
2星爪、鏈接GitHub 超時 ping github.com
ping github.com
解決辦法
1浆西、找到 github.com 的 IP 地址 ping github.com
訪問 https://www.ipaddress.com
在展示的輸入框中輸入 github.com 及 github.global.ssl.fastly.net
分別查詢獲取對應的 ip 地址
image.png
MAC 解決方案
sudo vi /etc/hosts
添加
140.82.113.3 github.com
image.png
3、問題
Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git`
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/hj/.cocoapods/repos` or via `pod repo add`.
image.png
解決版本
sudo rm -fr ~/.cocoapods/repos/master
4顽腾、問題
Analyzing dependencies
[!] Couldn't determine repo type for URL: `https://github.com/CocoaPods/Specs.git`: Net::OpenTimeout
image.png
解決1: 注釋掉 podfile 文件中的
#source 'https://github.com/CocoaPods/Specs.git'
解決2:
- podfile文件中指定 source 源為 master:
source 'https://github.com/CocoaPods/Specs.git'
- 執(zhí)行
pod repo remove trunk
移除trunk
源
執(zhí)行完后近零,pod search
就都正常了!