如何安裝Cocoa pods及問題解決方案

使用cocoa pods可以很方便的管理自己要使用的第三方框架,自動(dòng)引入框架所依賴的其他框架,自動(dòng)更新框架,方便組件化開發(fā),并且可以節(jié)省內(nèi)存,所以非常推薦使用這個(gè)東西.

但是安裝cocoa pods時(shí)候會(huì)遇到一些問題(通常是ruby版本過低或者brew的問題),以下使用終端給出解決方案.

加粗的命令代碼是需要在終端中打入的:

(1)sudo gem installcocoapods

Fetching: i18n-0.7.0.gem (100%)

Successfully installed i18n-0.7.0

Fetching: thread_safe-0.3.5.gem (100%)

Successfully installed thread_safe-0.3.5

Fetching: tzinfo-1.2.2.gem (100%)

Successfully installed tzinfo-1.2.2

Fetching: minitest-5.9.0.gem (100%)

Successfully installed minitest-5.9.0

Fetching: concurrent-ruby-1.0.2.gem (100%)

Successfully installed concurrent-ruby-1.0.2

Fetching: activesupport-5.0.0.gem (100%)

ERROR:Error installing cocoapods:

activesupport requires Ruby version >= 2.2.2.

//ruby的版本號(hào)過低

(2)ruby -v

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]

//的確是版本號(hào)太低了

(3)curl -L get.rvm.io | bash -s stable

% Total% Received % XferdAverage SpeedTimeTimeTimeCurrent

DloadUploadTotalSpentLeftSpeed

100184100184002060 --:--:-- --:--:-- --:--:--209

100 22865100 22865001143100:00:020:00:02 --:--:--187k

Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz

Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc

Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc',

but no GPG software exists to validate it, skipping.

Installing RVM to /Users/zzh/.rvm/

Adding rvm PATH line to /Users/baidu/.profile /Users/baidu/.mkshrc /Users/baidu/.bashrc /Users/baidu/.zshrc.

Adding rvm loading line to /Users/baidu/.profile /Users/baidu/.bash_profile /Users/baidu/.zlogin.

Installation of RVM in /Users/zzh/.rvm/ is almost complete:

* To start using RVM you need to run `source /Users/baidu/.rvm/scripts/rvm`

in all your open shell windows, in rare cases you need to reopen all shell windows.

# zzz,

#

#Thank you for using RVM!

#We sincerely hope that RVM helps to make your life easier and more enjoyable!!!

#

# ~Wayne, Michal & team.

In case of problems:https://rvm.io/helpandhttps://twitter.com/rvm_io

(4)接著執(zhí)行以下三條命令:

zzh:~ zzh$source ~/.bashrc

zzh:~ zzh$source ~/.bash_profile

zzh~ zzh$rvm -v

rvm 1.27.0 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

zzh:~ zzh$ruby -v

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]

(5)開始用rvm安裝ruby

zzh:~zzh$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-head

ruby-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

(6)選擇一個(gè)版本號(hào)開始安裝,選最新的2.3

zzh:~ zzh$rvm install 2.3

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.11/x86_64/ruby-2.3.0.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx.

Installing requirements for osx.

Updating system.......

Error running 'requirements_osx_brew_update_system ruby-2.3.0',

showing last 15 lines of /Users/baidu/.rvm/log/1470726560_ruby-2.3.0/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.

//結(jié)果出錯(cuò)了,打開/Users/baidu/.rvm/log/1470726560_ruby-2.3.0/update_system.log文件,好像是brew沒有升級(jí)

(7)升級(jí)brew

zhangzhihui:~ baidu$brew update

To restore the stashed changes to /usr/local/Library/Taps/homebrew/homebrew-core run:

'cd /usr/local/Library/Taps/homebrew/homebrew-core && git stash pop'

Updated 1 tap (homebrew/core).

==>New Formulae

alotconvoxgenext2fshyperlibvtermmimeticoscprestotboxwireguard-tools

b2sumdigdaggit-remote-hglegolivestreamerminioosm-gps-maprancher-clitodolist

==>Updated Formulae

abcm2psdateutilsglibmmlibdapntlscour

abducodatomicglidelibdrawtextntopngsdb

abi-compliance-checkerdavmailglyrlibebmlnuxeosec

==>Renamed Formulae

commonmark -> cmark

==>Deleted Formulae

avidemuxgimpkdiff3luytenosxfuseshrewsoft-vpn-clientswatchbooker

(8)再次安裝ruby 2.3

zzh:~ zzh$rvm install 2.3

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.11/x86_64/ruby-2.3.0.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx.

Installing requirements for osx.

Updating system.....

Installing required packages: automake...

Error running 'requirements_osx_brew_libs_install automake',

showing last 15 lines of /Users/zzh/.rvm/log/1470726877_ruby-2.3.0/package_install_automake.log

++ case "$1" in

++ [[ -t 1 ]]

++ return 1

++ printf %b 'There were package installation errors, make sure to read the log.

Try `brew tap --repair` and make sure `brew doctor` looks reasonable.

Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation\n'

There were package installation errors, make sure to read the log.

Try `brew tap --repair` and make sure `brew doctor` looks reasonable.

Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation

++ case "$_system_version" in

++ return 1

Requirements installation failed with status: 1.

//還是有問題

(9)打開/Users/zzh/.rvm/log/1470726877_ruby-2.3.0/package_install_automake.log文件,發(fā)現(xiàn)是automake和autoconf雖然安裝了,但是沒有鏈接上。如下面所示:

zzh:~ zzh$brew install autoconf

Warning: autoconf-2.69 already installed, it's just not linked

zzh:~ zzh$ brew install automake

Warning: automake-1.15 already installed, it's just not linked

//只是沒有連接,只要重新鏈接就可以了,如下:

zzh:~ zzh$brew link --overwrite autoconf

Linking /usr/local/Cellar/autoconf/2.69... 60 symlinks created

Warning: autoconf-2.69 already installed

zzh:~ zzh$ brew link --overwrite automake

Linking /usr/local/Cellar/automake/1.15... 124 symlinks created

(10)重新安裝ruby 2.3

zzh:~ zzh$rvm install 2.3

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.11/x86_64/ruby-2.3.0.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx.

==>Upgrading 1 outdated package, with result:

pkg-config 0.29.1_1

==>Upgrading pkg-config

==>Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_1.el_capitan.bottle.tar.gz

######################################################################## 100.0%

==>Pouring pkg-config-0.29.1_1.el_capitan.bottle.tar.gz

??/usr/local/Cellar/pkg-config/0.29.1_1: 10 files, 627.3K

Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.

Requirements installation successful.

Installing Ruby from source to: /Users/baidu/.rvm/rubies/ruby-2.3.0, this may take a while depending on your cpu(s)...

ruby-2.3.0 - #downloading ruby-2.3.0, this may take a while depending on your connection...

% Total% Received % XferdAverage SpeedTimeTimeTimeCurrent

DloadUploadTotalSpentLeftSpeed

100 13.5M100 13.5M005209k00:00:020:00:02 --:--:-- 5432k

ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/baidu/.rvm/src/ruby-2.3.0....

ruby-2.3.0 - #configuring...........................................................

ruby-2.3.0 - #post-configuration.

ruby-2.3.0 - #compiling.............................................................

ruby-2.3.0 - #installing.........

ruby-2.3.0 - #making binaries executable..

Installed rubygems 2.5.1 is newer than 2.4.8 provided with installed ruby, skipping installation, use --force to force installation.

ruby-2.3.0 - #gemset created /Users/baidu/.rvm/gems/ruby-2.3.0@global

ruby-2.3.0 - #importing gemset /Users/baidu/.rvm/gemsets/global.gems...............................................

ruby-2.3.0 - #generating global wrappers........

ruby-2.3.0 - #gemset created /Users/baidu/.rvm/gems/ruby-2.3.0

ruby-2.3.0 - #importing gemsetfile /Users/baidu/.rvm/gemsets/default.gems evaluated to empty gem list

ruby-2.3.0 - #generating default wrappers........

ruby-2.3.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).

Install of ruby-2.3.0 - #complete

Ruby was built without documentation, to build it run: rvm docs generate-ri

//終于搞定了。繼續(xù)

(11)安裝cocoapods

zzh:~ zzh$sudo gem install cocoapods

Password:

Fetching: i18n-0.7.0.gem (100%)

Successfully installed i18n-0.7.0

Fetching: thread_safe-0.3.5.gem (100%)

Successfully installed thread_safe-0.3.5

Fetching: tzinfo-1.2.2.gem (100%)

Successfully installed tzinfo-1.2.2

Fetching: concurrent-ruby-1.0.2.gem (100%)

Successfully installed concurrent-ruby-1.0.2

Fetching: activesupport-5.0.0.gem (100%)

Successfully installed activesupport-5.0.0

Fetching: nap-1.1.0.gem (100%)

Successfully installed nap-1.1.0

Fetching: fuzzy_match-2.0.4.gem (100%)

Successfully installed fuzzy_match-2.0.4

Fetching: cocoapods-core-1.0.1.gem (100%)

Successfully installed cocoapods-core-1.0.1

Fetching: claide-1.0.0.gem (100%)

Successfully installed claide-1.0.0

Fetching: cocoapods-deintegrate-1.0.0.gem (100%)

Successfully installed cocoapods-deintegrate-1.0.0

Fetching: cocoapods-downloader-1.1.0.gem (100%)

Successfully installed cocoapods-downloader-1.1.0

Fetching: cocoapods-plugins-1.0.0.gem (100%)

Successfully installed cocoapods-plugins-1.0.0

Fetching: cocoapods-search-1.0.0.gem (100%)

Successfully installed cocoapods-search-1.0.0

Fetching: cocoapods-stats-1.0.0.gem (100%)

Successfully installed cocoapods-stats-1.0.0

Fetching: netrc-0.7.8.gem (100%)

Successfully installed netrc-0.7.8

Fetching: cocoapods-trunk-1.0.0.gem (100%)

Successfully installed cocoapods-trunk-1.0.0

Fetching: cocoapods-try-1.1.0.gem (100%)

Successfully installed cocoapods-try-1.1.0

Fetching: molinillo-0.4.5.gem (100%)

Successfully installed molinillo-0.4.5

Fetching: colored-1.2.gem (100%)

Successfully installed colored-1.2

Fetching: xcodeproj-1.2.0.gem (100%)

Successfully installed xcodeproj-1.2.0

Fetching: escape-0.0.4.gem (100%)

Successfully installed escape-0.0.4

Fetching: fourflusher-0.3.2.gem (100%)

Successfully installed fourflusher-0.3.2

Fetching: cocoapods-1.0.1.gem (100%)

Successfully installed cocoapods-1.0.1

Parsing documentation for i18n-0.7.0

Installing ri documentation for i18n-0.7.0

Parsing documentation for thread_safe-0.3.5

Installing ri documentation for thread_safe-0.3.5

Parsing documentation for tzinfo-1.2.2

Installing ri documentation for tzinfo-1.2.2

Parsing documentation for concurrent-ruby-1.0.2

Installing ri documentation for concurrent-ruby-1.0.2

Parsing documentation for activesupport-5.0.0

Installing ri documentation for activesupport-5.0.0

Parsing documentation for nap-1.1.0

Installing ri documentation for nap-1.1.0

Parsing documentation for fuzzy_match-2.0.4

Installing ri documentation for fuzzy_match-2.0.4

Parsing documentation for cocoapods-core-1.0.1

Installing ri documentation for cocoapods-core-1.0.1

Parsing documentation for claide-1.0.0

Installing ri documentation for claide-1.0.0

Parsing documentation for cocoapods-deintegrate-1.0.0

Installing ri documentation for cocoapods-deintegrate-1.0.0

Parsing documentation for cocoapods-downloader-1.1.0

Installing ri documentation for cocoapods-downloader-1.1.0

Parsing documentation for cocoapods-plugins-1.0.0

Installing ri documentation for cocoapods-plugins-1.0.0

Parsing documentation for cocoapods-search-1.0.0

Installing ri documentation for cocoapods-search-1.0.0

Parsing documentation for cocoapods-stats-1.0.0

Installing ri documentation for cocoapods-stats-1.0.0

Parsing documentation for netrc-0.7.8

Installing ri documentation for netrc-0.7.8

Parsing documentation for cocoapods-trunk-1.0.0

Installing ri documentation for cocoapods-trunk-1.0.0

Parsing documentation for cocoapods-try-1.1.0

Installing ri documentation for cocoapods-try-1.1.0

Parsing documentation for molinillo-0.4.5

Installing ri documentation for molinillo-0.4.5

Parsing documentation for colored-1.2

Installing ri documentation for colored-1.2

Parsing documentation for xcodeproj-1.2.0

Installing ri documentation for xcodeproj-1.2.0

Parsing documentation for escape-0.0.4

Installing ri documentation for escape-0.0.4

Parsing documentation for fourflusher-0.3.2

Installing ri documentation for fourflusher-0.3.2

Parsing documentation for cocoapods-1.0.1

Installing ri documentation for cocoapods-1.0.1

Done installing documentation for i18n, thread_safe, tzinfo, concurrent-ruby, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, colored, xcodeproj, escape, fourflusher, cocoapods after 20 seconds

23 gems installed

(12)運(yùn)行pod setup

zzh:~ zzh$pod setup

Setting up CocoaPods master repo

CocoaPods 1.1.0.beta.1 is available.

To update use: `sudo gem install cocoapods --pre`

[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.1.0.beta.1

Setup completed

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 227,533評(píng)論 6 531
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,055評(píng)論 3 414
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 175,365評(píng)論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,561評(píng)論 1 307
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,346評(píng)論 6 404
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 54,889評(píng)論 1 321
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 42,978評(píng)論 3 439
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,118評(píng)論 0 286
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,637評(píng)論 1 333
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,558評(píng)論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,739評(píng)論 1 369
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,246評(píng)論 5 355
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 43,980評(píng)論 3 346
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,362評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,619評(píng)論 1 280
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 51,347評(píng)論 3 390
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,702評(píng)論 2 370

推薦閱讀更多精彩內(nèi)容