Cocoapods安裝過程

滴水微瀾發表於2017-11-06

1.升級Ruby環境

gem -v

gem update --system

如果沒有許可權去升級Ruby ?就輸入

sudo gem update --system

 

2.換掉Ruby映象

首先移除現有的Ruby映象

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

新增國內最新映象源

gem source -a https://gems.ruby-china.org/

檢視當前映象

gem sources -l

 

3.安裝CocoaPods

sudo gem install cocoapods

如果報錯

sudo gem install -n /usr/local/bin cocoapods

 

4.初始化repos檔案

pod repo add master https://github.com/CocoaPods/Specs.git

報錯用這個

pod setup

 

5.安裝過程中出現報錯

報錯型別1:

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

 

Cloning into 'master'...

fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Could not resolve host: github.com

 

原因可能是:github.com沒有被主機給解析

解決方法:在本地手動指定github.com的IP地址

 

編輯檔案etc/hosts

sudo vi /etc/hosts

 

新增github的地址

::1             localhost

192.30.255.112  github.com

 

 

報錯型別2:

[!] /usr/bin/git clone 'https://github.com/CocoaPods/Specs.git' master --depth=1

 

Cloning into 'master'...

 

fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Could not resolve host: github.com

 

原因可能是:安裝多個Xcdoexcode路徑問題

解決方法:sudo xcode-select -switch /Applications/Xcode.app/

 

在終端裡輸入下方命令可以知道Xcode的路徑:

xcode-select -p

相關文章