Cocoapods安裝過程

1.升級Ruby環境git

gem -vgithub

gem update --systemxcode

若是沒有權限去升級Ruby ?就輸入ruby

sudo gem update --systemapp

 

2.換掉Ruby鏡像code

首先移除現有的Ruby鏡像rem

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

添加國內最新鏡像源it

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

查看當前鏡像

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

相關文章
相關標籤/搜索