cocoapod最新安裝方法

1.移除現(xiàn)有的Ruby

$gem sources --remove https://rubygems.org/

2.使用淘寶鏡像

$gem sources -a https://ruby.taobao.org/

3.驗(yàn)證當(dāng)前ruby版本

$gem sources -l

成功后提示:

*** CURRENT SOURCES ***

https://ruby.taobao.org/

4.開始安裝cocoapods

$sudo gem install cocoapods

這時(shí)候提示:

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.

這個(gè)地方很坑絮记,之前安裝cocoapods一直是沒有這個(gè)問題的摔踱,這里提示Ruby版本要大于或等于2.2.2

于是查看ruby版本

$ruby -v

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

果然這里就要升級Ruby版本啦

查看目前的所有ruby版本:

$rvm list known

如果提示command not found 請先安裝rvm

$curl -L get.rvm.io | bash -s stable

如果已安裝會(huì)列出所有的ruby版本:

# 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

這里我們安裝2.2.2:

$rvm install 2.2.2

終端運(yùn)行結(jié)果:(如果直接成功請繞過homebrew的卸載安裝)

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.

About to install Homebrew, press `Enter` for default installation in `/usr/local`,

type new path if you wish custom Homebrew installation (the path needs to be writable for user)

:

回車:

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)"

The current contents of /usr/local are .git

Requirements installation failed with status: 1.

這里執(zhí)行:

$ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

卸載home-brew

Warning: This script will remove:

/Library/Caches/Homebrew/

/usr/local/.git/

Are you sure you want to uninstall Homebrew? [y/N] y

==>Removing Homebrew installation...

==>Removing empty directories...

==>Homebrew uninstalled!

You may want to restore /usr/local's original permissions

sudo chmod 0755 /usr/local

sudo chgrp wheel /usr/local

再執(zhí)行:

$ rvm install 2.2.2

提示:

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.

About to install Homebrew, press `Enter` for default installation in `/usr/local`,

type new path if you wish custom Homebrew installation (the path needs to be writable for user)

:

按回車:

==>This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/doc/homebrew

/usr/local/share/man/man1/brew.1

/usr/local/share/zsh/site-functions/_brew

/usr/local/etc/bash_completion.d/brew

Press RETURN to continue or any other key to abort

==>/usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew

Password:

這里需要輸入電腦密碼:

==>/usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==>/usr/bin/sudo /usr/sbin/chown haha /Library/Caches/Homebrew

==>Downloading and installing Homebrew...

remote: Counting objects: 501, done.

remote: Compressing objects: 100% (445/445), done.

remote: Total 501 (delta 29), reused 360 (delta 27), pack-reused 0

Receiving objects: 100% (501/501), 787.83 KiB | 169.00 KiB/s, done.

Resolving deltas: 100% (29/29), done.

From https://github.com/Homebrew/brew

* [new branch]? ? ? master ? ? -> origin/master

HEAD is now at 32f7e73 download_strategy: ensure fixed commit hash length

==>Tapping homebrew/core

Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...

remote: Counting objects: 3714, done.

remote: Compressing objects: 100% (3598/3598), done.

remote: Total 3714 (delta 14), reused 2112 (delta 6), pack-reused 0

Receiving objects: 100% (3714/3714), 2.88 MiB | 240.00 KiB/s, done.

Resolving deltas: 100% (14/14), done.

Checking connectivity... done.

Checking out files: 100% (3717/3717), done.

Tapped 3591 formulae (3,740 files, 9.0M)

==>Installation successful!

==>Next steps

Run `brew help` to get started

Further documentation: https://git.io/brew-docs

==>Homebrew has enabled anonymous aggregate user behaviour analytics

Read the analytics documentation (and how to opt-out) here:

https://git.io/brew-analytics

Installing requirements for osx.

Updating system.....

Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl........

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

Requirements installation successful.

ruby-2.2.2 - #configure

ruby-2.2.2 - #download

% Total? ? % Received % Xferd? Average Speed ? Time? ? Time ? ? Time? Current

Dload? Upload ? Total ? Spent? ? Left? Speed

100 6854k? 100 6854k? ? 0 ? ? 0? 61342? ? ? 0? 0:01:54? 0:01:54 --:--:--? 132k

ruby-2.2.2 - #validate archive

ruby-2.2.2 - #extract

ruby-2.2.2 - #validate binary

ruby-2.2.2 - #setup

ruby-2.2.2 - #gemset created /Users/haha/.rvm/gems/ruby-2.2.2@global

ruby-2.2.2 - #importing gemset /Users/haha/.rvm/gemsets/global.gems..............................

ruby-2.2.2 - #generating global wrappers........

ruby-2.2.2 - #gemset created /Users/haha/.rvm/gems/ruby-2.2.2

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

ruby-2.2.2 - #generating default wrappers........

Updating certificates in '/etc/openssl/cert.pem'.

mkdir: /etc/openssl: Permission denied

mkdir -p "/etc/openssl" failed, retrying with sudo

haha password required for 'mkdir -p /etc/openssl':

and sudo mkdir worked

這樣ruby2.2.2就安裝好了

現(xiàn)在就可以安裝cocoapods啦:

$sudo gem install cocoapods

看看這樣cocoapods就安裝成功了

Fetching: nap-1.1.0.gem (100%)

Successfully installed nap-1.1.0

Fetching: fourflusher-0.3.2.gem (100%)

Successfully installed fourflusher-0.3.2

Fetching: escape-0.0.4.gem (100%)

Successfully installed escape-0.0.4

Fetching: colored-1.2.gem (100%)

Successfully installed colored-1.2

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

Successfully installed concurrent-ruby-1.0.2

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: i18n-0.7.0.gem (100%)

Successfully installed i18n-0.7.0

Fetching: activesupport-5.0.0.gem (100%)

Successfully installed activesupport-5.0.0

Fetching: claide-1.0.0.gem (100%)

Successfully installed claide-1.0.0

Fetching: xcodeproj-1.1.0.gem (100%)

Successfully installed xcodeproj-1.1.0

Fetching: molinillo-0.4.5.gem (100%)

Successfully installed molinillo-0.4.5

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

Successfully installed cocoapods-try-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-stats-1.0.0.gem (100%)

Successfully installed cocoapods-stats-1.0.0

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

Successfully installed cocoapods-search-1.0.0

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

Successfully installed cocoapods-plugins-1.0.0

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

Successfully installed cocoapods-downloader-1.0.1

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

Successfully installed cocoapods-deintegrate-1.0.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: cocoapods-1.0.1.gem (100%)

Successfully installed cocoapods-1.0.1

Parsing documentation for nap-1.1.0

Installing ri documentation for nap-1.1.0

Parsing documentation for fourflusher-0.3.2

Installing ri documentation for fourflusher-0.3.2

Parsing documentation for escape-0.0.4

Installing ri documentation for escape-0.0.4

Parsing documentation for colored-1.2

Installing ri documentation for colored-1.2

Parsing documentation for concurrent-ruby-1.0.2

Installing ri documentation for concurrent-ruby-1.0.2

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 i18n-0.7.0

Installing ri documentation for i18n-0.7.0

Parsing documentation for activesupport-5.0.0

Installing ri documentation for activesupport-5.0.0

Parsing documentation for claide-1.0.0

Installing ri documentation for claide-1.0.0

Parsing documentation for xcodeproj-1.1.0

Installing ri documentation for xcodeproj-1.1.0

Parsing documentation for molinillo-0.4.5

Installing ri documentation for molinillo-0.4.5

Parsing documentation for cocoapods-try-1.0.0

Installing ri documentation for cocoapods-try-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-stats-1.0.0

Installing ri documentation for cocoapods-stats-1.0.0

Parsing documentation for cocoapods-search-1.0.0

Installing ri documentation for cocoapods-search-1.0.0

Parsing documentation for cocoapods-plugins-1.0.0

Installing ri documentation for cocoapods-plugins-1.0.0

Parsing documentation for cocoapods-downloader-1.0.1

Installing ri documentation for cocoapods-downloader-1.0.1

Parsing documentation for cocoapods-deintegrate-1.0.0

Installing ri documentation for cocoapods-deintegrate-1.0.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 cocoapods-1.0.1

Installing ri documentation for cocoapods-1.0.1

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 146 seconds

23 gems installed


到這里,就算ruby升級成功了

5.安裝cocoapods

(1)$ sudo gem install -n /usr/local/bin cocoapods

(2)pod setup


6..更新gem (此步驟可省略怨愤,現(xiàn)在的蘋果系統(tǒng)是自帶gem的昌渤,不影響使用)

sudo gem update --system(執(zhí)行此步驟有很多坑,還得具體問題具體分析)


使用流程:

1.新建工程憔四,并在終端用cd指令到路徑 (按Alt鍵 拖拽文件到終端會(huì)自動(dòng)添加文件路徑,cd后加一個(gè)空格)

如下圖:


(2)新建文件 “Podfile”

格式如下:


(3)pod init

? ?(4) pod install 這個(gè)時(shí)候要多等會(huì)

? 裝好后如下圖:


主要參考倆位博主的博客裝cocoapods


http://blog.csdn.net/u012960049/article/details/52275272

http://blog.sina.com.cn/s/blog_89f4ddfd0102ww3t.html

最后膀息!歡迎加入iOS技術(shù)大群,學(xué)習(xí)知識(shí)交更多的同行朋友 ? ? ? ? ? ? QQ群號(hào):580284575

群二維碼:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末了赵,一起剝皮案震驚了整個(gè)濱河市潜支,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌柿汛,老刑警劉巖冗酿,帶你破解...
    沈念sama閱讀 206,968評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異络断,居然都是意外死亡裁替,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,601評論 2 382
  • 文/潘曉璐 我一進(jìn)店門貌笨,熙熙樓的掌柜王于貴愁眉苦臉地迎上來弱判,“玉大人,你說我怎么就攤上這事锥惋〔” “怎么了?”我有些...
    開封第一講書人閱讀 153,220評論 0 344
  • 文/不壞的土叔 我叫張陵膀跌,是天一觀的道長遭商。 經(jīng)常有香客問我,道長捅伤,這世上最難降的妖魔是什么劫流? 我笑而不...
    開封第一講書人閱讀 55,416評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮丛忆,結(jié)果婚禮上祠汇,老公的妹妹穿的比我還像新娘。我一直安慰自己蘸际,他們只是感情好座哩,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,425評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著粮彤,像睡著了一般根穷。 火紅的嫁衣襯著肌膚如雪姜骡。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,144評論 1 285
  • 那天屿良,我揣著相機(jī)與錄音圈澈,去河邊找鬼。 笑死尘惧,一個(gè)胖子當(dāng)著我的面吹牛康栈,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播喷橙,決...
    沈念sama閱讀 38,432評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼阿纤,長吁一口氣:“原來是場噩夢啊……” “哼亿眠!你這毒婦竟也來了道批?” 一聲冷哼從身側(cè)響起错洁,我...
    開封第一講書人閱讀 37,088評論 0 261
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎疙剑,沒想到半個(gè)月后氯迂,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,586評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡言缤,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,028評論 2 325
  • 正文 我和宋清朗相戀三年嚼蚀,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片管挟。...
    茶點(diǎn)故事閱讀 38,137評論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡轿曙,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出哮独,到底是詐尸還是另有隱情拳芙,我是刑警寧澤察藐,帶...
    沈念sama閱讀 33,783評論 4 324
  • 正文 年R本政府宣布皮璧,位于F島的核電站,受9級特大地震影響分飞,放射性物質(zhì)發(fā)生泄漏悴务。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,343評論 3 307
  • 文/蒙蒙 一譬猫、第九天 我趴在偏房一處隱蔽的房頂上張望讯檐。 院中可真熱鬧,春花似錦染服、人聲如沸别洪。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,333評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽挖垛。三九已至痒钝,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間痢毒,已是汗流浹背送矩。 一陣腳步聲響...
    開封第一講書人閱讀 31,559評論 1 262
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留哪替,地道東北人栋荸。 一個(gè)月前我還...
    沈念sama閱讀 45,595評論 2 355
  • 正文 我出身青樓,卻偏偏與公主長得像凭舶,于是被迫代替她去往敵國和親晌块。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,901評論 2 345

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