1.打開終端
2 移除現(xiàn)有 Ruby 默認(rèn)源 輸入以下指令
$gem sources --remove https://rubygems.org/
3.使用新的源 輸入以下指令
$gem sources -a https://ruby.taobao.org/
4.驗(yàn)證新源是否替換成功 輸入以下指令
$gem sources -l
5.安裝 CocoaPods
$sudo gem install cocoa pods
//–––––––––––那么問題來了——沒遇到的自動跳過————————————
錯誤提示1
Error installing cocoapods:? activesupport requires Ruby version >= 2.2.2.
解決方案 :
1串绩、安裝 RVM baby 版本管理器
$ curl -L get.rvm.io | bash -s stable
//________等安裝完成 出現(xiàn)下面這行提示以下___________
In case of problems: https://rvm.io/helpandhttps://twitter.com/rvm_io
執(zhí)行
$source ~/.bashrc
$source ~/.bash_profile
測試是否安裝正常
$rvm -v
//________提示以下___________
rvm 1.27.0 (latest) by Wayne E. Seguin, Michal Papis[https://rvm.io/]
2诊赊、用RVM升級Ruby查看當(dāng)前ruby版本
$ruby -v
$rvm list known
//________提示以下___________
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.8]
[ruby-]2.2[.4]
[ruby-]2.3[.0]
[ruby-]2.2-headruby-head
# for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.23]
jruby[-9.0.5.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx[-2.5.8]
rbx-head
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# GoRuby
goruby
# Topaz
topaz
# MagLev
maglev[-head]
maglev-1.0.0
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
//___________________
安裝ruby 2.2.2 執(zhí)行
$rvm install 2.2.2
干貨1:
安裝ruby遇到" Installing Homebrew - Brew Command Not Found"命令找不到解決方案:
Check XCode is installed or not.
$gcc --version
$ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$brew doctor
$brew update.
完成后 執(zhí)行
$ruby -v
//–––––打印輸出–––––––
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
6 繼續(xù)安裝 CocoaPods
$sudo gem install cocoa pods
//______安裝成功提示如下______
Done installing documentation for nap, fourflusher, escape, colored, concurrent-ruby, thread_safe, tzinfo, i18n, activesupport, claide, xcodeproj, molinillo, cocoapods-try, netrc, cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, fuzzy_match, cocoapods-core, cocoapods after 21 seconds,23 gems installed
$pod setup
備注:蘋果系統(tǒng)升級 OS X EL Capitan 后安裝改為:
$sudo gem install -n /usr/local/bin cocoapods
$pod setup
干貨2:
CocoaPods無限卡在Setting up CocoaPods master repo解決方案:
對于初次使用CocoaPods的同學(xué)著角,即使你不使用pod setup命令尤蛮,在你初次執(zhí)行pod install命令時,系統(tǒng)也會自動執(zhí)行pod setup菠镇。而由于網(wǎng)絡(luò)不穩(wěn)定的原因芳撒,不掛VPN是不可能成功執(zhí)行pod setup的房轿。(我大天朝的墻啊~~~~)
$ pod repo remove master
$ git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master
$ pod repo update
7?更新 gem
$sudo gem update --system
8 新建工程,并在終端用 cd 指令到文件夾內(nèi)
$pod search 第三方
9 新建 Podfile 文件
$ touch Podfile
10 編輯 Podfile 文件栽渴,并寫入要添加的第三方庫(cocoapod1.0.1版本Podfile文件的內(nèi)容格式要求發(fā)生了變化尖坤,必須指出指出所用第三方庫的target)
platform:ios, '8.0'
#use_frameworks!個別需要用到它,比如reactiveCocoa
target 'XXXApp' do
pod 'AFNetworking', '~> 2.3.1'<-------第三方
end
11 導(dǎo)入第三方庫
$pod install --no-repo-update
12 退出終端