安裝淘寶源就直接跳過,安裝十余次,分享下最近安裝cocoapods的經(jīng)驗(yàn),僅僅提醒ruby版本問題之后的操作.如果還有不懂地方可以下方評(píng)論,會(huì)及時(shí)回答.
Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
1.安裝ruby
1>安裝 RVM
RVM: Ruby Version Manager, Ruby的版本管理器卿嘲,包括Ruby的版本管理和Gem庫管理(gemset)
curl -L get.rvm.io | bash -s stable
2>安裝home-brew(切記先安裝home-brew,再安裝ruby!!)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
home-brew地址:<--
如果出現(xiàn)重復(fù)安裝home-brew,不要怕.
會(huì)給你提示命令.
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
3>查詢r(jià)vm中的ruby版本
rvm list known
4>再安裝ruby版本(最新版本2.3.0)
rvm install 2.3.0
出現(xiàn)情況:
1.安裝不通過的話可以進(jìn)行手動(dòng)安裝.
Installing requirements for osx.
Updating system.....
Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl|
........
Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libksba openssl',
showing last 15 lines of /Users/MTKJ/.rvm/log/1469285314_ruby-2.3.0/package_install_autoconf_automake_libtool_pkg-config_libyaml_readline_libksba_openssl.log
brew install autoconf
brew install automake
brew install lib tool
brew install apple-gcc42
brew install libyaml
brew install libxslt
brew install libksba
brew install openssl
2 . Error running '__rvm_make -j 1' 錯(cuò)誤
ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/xxxx/.rvm/src/ruby-2.3.0...-
ruby-2.3.0 - #configuring......................................................|
ruby-2.3.0 - #post-configuration.
ruby-2.3.0 - #compiling...........
Error running '__rvm_make -j 1',
showing last 15 lines of /Users/xxxx/.rvm/log/1476689284_ruby-2.3.0/make.log
compiling dln.c
compiling localeinit.c
creating verconf.h
verconf.h updated
compiling loadpath.c
compiling prelude.c
linking static-library libruby.2.3.0-static.a
verifying static-library libruby.2.3.0-static.a
linking shared-library libruby.2.3.0.dylib
generating encdb.h
encdb.h updated
making enc
/bin/sh: /Applications/Xcode: No such file or directory
make: *** [enc] Error 127
++ return 2
There has been an error while running make. Halting the installation.
/Users/xxxx/.rvm/bin/rvm: line 66: shell_session_update: command not found
- 安裝xcode command line 后再次安裝ruby.
xcode-select --install
- 如果還是沒有成功,查看自己xcode command line 是否選在正確版本.
4>出現(xiàn)錯(cuò)誤了,還是沒有安裝成功ruby.(沒關(guān)系,卸載RVM,從新安裝!)
要記得關(guān)閉終端重新打開, 或者打開路徑cd ~
出現(xiàn)在~
sudo rm -rf .rvm .rvmrc /etc/rvmrc ;gem uninstall rvm
2.安裝CocoaPods
1>安裝cocoapods(普通版本)
sudo gem install cocoapods
2>更新框架庫
pod setup
可以查看框架鏡像庫的cd ~/.cocoapods
3>更新cocoapods版本(測(cè)試版本,僅供特定條件)
sudo gem install cocoapods --pre
4>指定安裝cocoapods版本
sudo gem install cocoapods --version 1.0.1
出現(xiàn)情況:
- Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
問題是因?yàn)間em 的ruby 鏡像源發(fā)生了更換,切換鏡像源即可债鸡。
https://gems.ruby-china.org => https://gems.ruby-china.com
// 查看 鏡像源
gem sources -l
// 刪除 鏡像源
gem sources --remove https://gems.ruby-china.org
// 添加 鏡像源
gem sources -a https://gems.ruby-china.com
詳情可參照ruby中國鏡像社區(qū): https://gems.ruby-china.com/