當你按現(xiàn)有的順序安裝cocoapods的時候
1.移除現(xiàn)有的Ruby
$gem sources --remove https://rubygems.org/
2.使用淘寶鏡像
$gem sources -a https://ruby.taobao.org/
3.驗證當前ruby版本
$gem sources -l
成功后提示:
*** CURRENT SOURCES ***
https://ruby.taobao.org/
4.開始安裝cocoapods
$sudo gem install cocoa pods
這時候會出現(xiàn)提示离例,需要你升級Ruby
使用ruby -v查看你現(xiàn)有的版本
結(jié)果是:ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
使用ruby list known查看ruby所有版本
如果提示command not found 請先安裝rvm
curl -L get.rvm.io | bash -s stable(安裝ram命令)
查看ruby版本后發(fā)現(xiàn)我們的版本確實太低了,這時候終端輸入rvm install 2.2.2
如果出現(xiàn)這種錯誤:
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.11/x86_64/ruby-2.2.2.tar.bz2
Checking requirements for osx.
Installing requirements for osx.
Updating system.........
Error running 'requirements_osx_brew_update_system ruby-2.2.2',
showing last 15 lines of /Users/chuanchunli/.rvm/log/1473597554_ruby-2.2.2/update_system.log
https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.'
++ rvm_pretty_print stderr
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'Failed to update Homebrew, follow instructions here:
https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.\n'
Failed to update Homebrew, follow instructions here:
https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.
++ return 1
Requirements installation failed with status: 1.
不要著急,下面告訴大家怎么做鄙信,本人在這里卡了一天
終端輸入
brew doctor
錯誤提示:
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: The following directories are not writable:
/usr/local/share/man
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.
You should change the ownership and permissions of these directories.
back to your user account.
sudo chown -R $(whoami) /usr/local/share/man
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
autoconf
libgpg-error
libtool
pig-config
在輸入:
sudo chown -R $(whoami) /usr/local/share/man
然后輸入
brew link autoconf
brew link libgpg-error
brew link libtool
brew link pig-config
最后再次輸入rvm install 2.2.2
這回就應該可以安裝cocoapods了
安裝cocoa pods命令:sudo gem install cocoapods