- 疫情期間,筆記本開機(jī)卡在進(jìn)度條界面匾嘱,不想給國家添麻煩斤斧,盡量不外出,所以在家格盤重裝系統(tǒng)了霎烙。安裝cocoapods很多次了撬讽,每次遇見不同的坑,所以把本次安裝的步驟記錄下來了悬垃,希望能幫助大家游昼,少踩坑。
- 我這次安裝完cocoapods版本是1.8.4尝蠕,之前安裝cocoapods很頭疼的一件事就是執(zhí)行 pod setup 命令烘豌,進(jìn)入漫長的等待,網(wǎng)上有人提供方法把cocoapods倉庫離線下載看彼,然后放到目錄里廊佩,很實(shí)用!我文章最后也會把鏈接附上闲昭。但是 罐寨,這次安裝完1.8.4這個版本后,我執(zhí)行 pod setup 命令后序矩,終端沒有去下載倉庫鸯绿,我也沒有手動導(dǎo)入離線倉庫,也安裝成功了,大家安裝成功后請給我留言瓶蝴,謝謝毒返!
1.升級ruby環(huán)境
如果ruby版本太低,安裝cocoapods時會有警告:
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0/specifications/nokogiri-1.5.6.gemspec:22.
- 先安裝好 RVM舷手,在終端如下命令:
curl -L https://get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
正常終端會輸出下面的結(jié)果:
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Installing RVM to /Users/HaitaoLee/.rvm/
Adding rvm PATH line to /Users/HaitaoLee/.profile /Users/HaitaoLee/.mkshrc /Users/HaitaoLee/.bashrc /Users/HaitaoLee/.zshrc.
Adding rvm loading line to /Users/HaitaoLee/.profile /Users/HaitaoLee/.bash_profile /Users/HaitaoLee/.zlogin.
Installation of RVM in /Users/HaitaoLee/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/HaitaoLee/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM ??
Please consider donating to our open collective to help us maintain RVM.
?? Donate: https://opencollective.com/rvm/donate
但是運(yùn)氣不好的我拧簸,又遇見新的坑了,如下男窟,又是網(wǎng)絡(luò)問題...盆赤,我查找原因的時候,很多人安裝HomeBrew也遇到這個問題歉眷。
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
我是在本地的hosts文件牺六,把151.101.76.133 raw.githubusercontent.com
加進(jìn)入就解決了,命令我放下面了汗捡,加到hosts最后一行就可以淑际。
sudo vi /etc/hosts
- 查看rvm版本
rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
- 列出ruby可安裝的版本信息
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[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.6]
[ruby-]2.5[.5]
[ruby-]2.6[.3] // 我安裝是這個……
[ruby-]2.7[.0-preview1] //預(yù)覽版
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby-9.1[.17.0]
jruby[-9.2.7.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.107]
rbx-4[.3]
rbx-head
# TruffleRuby
truffleruby[-19.1.0]
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1.3.0
mruby-1[.4.1]
mruby-2[.0.1]
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# Topaz
topaz
# MagLev
maglev-1.0.0
maglev-1.1[RC1]
maglev[-1.2Alpha4]
maglev-head
# 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.6.3版本,當(dāng)然你也可以選擇其他的)
rvm install 2.6.3
- 設(shè)置為默認(rèn)版本
rvm use 2.6.3 --default
2.更換Ruby鏡像
sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
驗(yàn)證是否添加成功
gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
3.安裝Cocoapods
sudo gem install -n /usr/local/bin cocoapods
Fetching thread_safe-0.3.6.gem
Fetching tzinfo-1.2.6.gem
Fetching concurrent-ruby-1.1.6.gem
Fetching nap-1.1.0.gem
Fetching i18n-0.9.5.gem
Fetching activesupport-4.2.11.1.gem
Fetching fuzzy_match-2.0.4.gem
Fetching httpclient-2.8.3.gem
Fetching algoliasearch-1.27.1.gem
Fetching cocoapods-core-1.8.4.gem
Fetching claide-1.0.3.gem
Fetching cocoapods-deintegrate-1.0.4.gem
Fetching cocoapods-downloader-1.3.0.gem
...
Successfully installed cocoapods-deintegrate-1.0.4
Successfully installed cocoapods-downloader-1.3.0
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-search-1.0.0
...
Parsing documentation for cocoapods-1.8.4
Installing ri documentation for cocoapods-1.8.4
Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, httpclient, algoliasearch, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 16 seconds
最后一步安裝本地庫扇住,pod setup
但是我這次執(zhí)行完命令后春缕,終端不作為。我在項(xiàng)目執(zhí)行pod install
和pod search
都成功了艘蹋。如果大家執(zhí)行pod setup后锄贼,下載倉庫進(jìn)入漫長。簿训。咱娶。。的等待强品,請參考下面的文章:
首次 pod setup 慢的取巧方法