2016最新的CocoPods安裝

A.打開終端

 $ ruby -v  #查看ruby的版本

打印代碼:

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

B. 更換ruby鏡像:

終端輸入如下命令(把Ruby鏡像指向taobao,避免被墻,你懂得)

a.移除現(xiàn)有 Ruby 默認(rèn)源輸入以下指令

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

C.使用新的源輸入以下指令 :

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

#淘寶源已經(jīng)停更了目前最新的是
$gem source -a https://gems.ruby-china.org

這里附上官網(wǎng)地址 --> RubyGems 鏡像- Ruby China

D.驗(yàn)證新源是否替換成功輸入以下指令:

$gem sources -l  #檢查源鏡像的

E.安裝cocoapods

$sudo gem install cocoa pods

這就遇到我的第一個(gè)問題:

如果你的ruby 版本過低 就會(huì)報(bào)錯(cuò):

ERROR:  Error installing cocoa:
    activesupport requires Ruby version >= 2.2.2.
ERROR:  Error installing pods:
    activesupport requires Ruby version >= 2.2.2.  

前幾天页藻,我就搞到這個(gè)地方澄干,嘗試了好幾種方法更新ruby 但是都沒有成功叛溢,今天偶然看到一個(gè)文章,你們可以看一下 作者:有種淡淡的憂傷 -->安裝CocoaPods過程和遇到各種坑

解決方案:

1. 安裝 RVM baby 版本管理器

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

打印代碼:

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

如上顯示說明安裝成功

2. 執(zhí)行文件

$ source ~/.bashrc  
$ source ~/.bash_profile  
$ rvm -v  

打印代碼:

rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com>[https://rvm.io/]

3. 用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-head
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[.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

4. 安裝ruby 2.2.2 版本

$rvm install 2.2.2

如果打佣凸贰:

    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/abc/.rvm/gems/ruby-2.2.2@global
    ruby-2.2.2 - #importing gemset/Users/abc/.rvm/gemsets/global.gems..............................
    ruby-2.2.2 - #generating global wrappers........
    ruby-2.2.2 - #gemset created /Users/abc/.rvm/gems/ruby-2.2.2
    ruby-2.2.2 - #importing gemsetfile /Users/abc/.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
    LiuWenqiang password required for 'mkdir -p /etc/openssl': 
    and sudo mkdir worked    

則說明安裝成功了

打印代碼:

Done with Command Line Tools (OS X 10.11) for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> Installing the Command Line Tools (expect a GUI popup):
==> /usr/bin/sudo /usr/bin/xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Failed during: /usr/bin/sudo /usr/bin/xcode-select --install
Requirements installation failed with status: 1.

如果安裝失敗

如果提示以下報(bào)錯(cuò)或警告:

解決方法:

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

注意,不一定是報(bào)這個(gè)錯(cuò),但是提示會(huì)告訴你解決方法轻纪,一般是缺少啥油额,然后提示你用哪個(gè)命令安裝

第二個(gè)問題:

解決方案:


$ sudo xcode-select --switch /Library/Developer/CommandLineTools/

Password: (輸入電腦權(quán)限密碼)

$ git

usage: git [--version] [--help] [-C <path>] [-c name=value]

[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]

[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]

[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]

<command> [<args>]

第二個(gè)問題就解決了

然后再重新執(zhí)行:安裝2.2.2版本 步驟 就可以解決

1. 查看當(dāng)前ruby 版本

$ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

現(xiàn)在ruby版本已經(jīng)是2.2.2了

第一個(gè)問題就解決了

2. 繼續(xù)安裝 CocoaPods

$sudo gem install cocoa pods
$sudo gem install -n /usr/local/bin cocoapods
$pod setup

3. 更新 gem

$sudo gem update --system

4. 新建一個(gè)項(xiàng)目,名字PodTest

5. 跳轉(zhuǎn)到項(xiàng)目路徑 $ cd 項(xiàng)目路徑 (中間有空格)

cd /Users/lucky/Desktop/PodTest   

6. 建立Podfile(配置文件)

$vim Podfile

鍵盤輸入 i 進(jìn)入編輯模式桐磁,輸入 不知道的可以自行百度鳥哥的私房菜.
簡單使用可以查看 VIM編輯器的使用

platform :ios, '8.0'

use_frameworks! #//通過指定use_frameworks!要求生成的是framework而不是靜態(tài)庫
inhibit_all_warnings! #//在全局指定不顯示所有所引用的庫中的警告信息

#這個(gè)不清楚的自己上GitHub上面看吧
target 'TestDemo' do

pod 'AFNetworking', '~> 3.0.4'
pod 'YYKit'
pod 'FMDB'
pod 'Masonry'

end

補(bǔ)充:

回車后反饋如下:

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 bin Cellar CODEOFCONDUCT.md CONTRIBUTING.md etc include lib Library LICENSE.txt opt README.md share SUPPORTERS.md .git .gitignore

提示的信息表示,已經(jīng)安裝好了,如果你想要?jiǎng)h掉 就鍵入如下代碼巴拉巴拉“`

并且我再次鍵入

$rvm install ruby-2.0.0-p643 

依舊報(bào)錯(cuò)

ERROR: '/usr/local/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.

得了,好好仔細(xì)看看報(bào)錯(cuò)內(nèi)容吧 not writable 不可寫入, 是不是安裝不上啊 然后百度到一條老外也出一樣的錯(cuò)誤 他是這么解決的
終端命令:

 $ rvm autolibs read-only # read more here:https://rvm.io/rvm/autolibs
 $ rvm install ruby

尼瑪,然后終端就瘋狂的開始下載了

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.2.1.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Skipping update of certificates in '/usr/local/etc/openssl/cert.pem', to force update run:
    rvm osx-ssl-certs update /usr/local/etc/openssl/cert.pem

Requirements installation successful.
Installing Ruby from source to: /Users/Aotu/.rvm/rubies/ruby-2.2.1, this may take a while depending on your cpu(s)...
ruby-2.2.1 - #downloading ruby-2.2.1, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.7M  100 12.7M    0     0   242k      0  0:00:53  0:00:53 --:--:--  230k
ruby-2.2.1 - #extracting ruby-2.2.1 to /Users/Aotu/.rvm/src/ruby-2.2.1....
ruby-2.2.1 - #applying patch /Users/Aotu/.rvm/patches/ruby/2.2.1/fix_installing_bundled_gems.patch.
ruby-2.2.1 - #configuring..........................................................
ruby-2.2.1 - #post-configuration.
ruby-2.2.1 - #compiling............................................................................................|
ruby-2.2.1 - #installing..........
ruby-2.2.1 - #making binaries executable..
ruby-2.2.1 - #downloading rubygems-2.4.8
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   154  100   154    0     0     46      0  0:00:03  0:00:03 --:--:--   129
100  437k  100  437k    0     0  74299      0  0:00:06  0:00:06 --:--:--  198k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.2.1 - #extracting rubygems-2.4.8....
ruby-2.2.1 - #removing old rubygems.........
ruby-2.2.1 - #installing rubygems-2.4.8......................
ruby-2.2.1 - #gemset created /Users/Aotu/.rvm/gems/ruby-2.2.1@global
ruby-2.2.1 - #importing gemset /Users/Aotu/.rvm/gemsets/global.gems................................................
ruby-2.2.1 - #generating global wrappers........
ruby-2.2.1 - #gemset created /Users/Aotu/.rvm/gems/ruby-2.2.1
ruby-2.2.1 - #importing gemsetfile /Users/Aotu/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.1 - #generating default wrappers........
ruby-2.2.1 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.2.1 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri

到此,ruby就安裝好了 而且我們注意看到 ruby 的安裝版本并不是2.0.0 ,而是2.2.1

事情并沒有這么就結(jié)束,我回頭再看報(bào)錯(cuò)的提示信息

ERROR: '/usr/local/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.

當(dāng)然 首先把安裝好的2.2.1刪掉 防止有哪些影響

rvm remove 2.2.1

ruby-2.2.1 - #removing src/ruby-2.2.1..
ruby-2.2.1 - #removing rubies/ruby-2.2.1..
ruby-2.2.1 - #removing gems....
ruby-2.2.1 - #removing aliases
ruby-2.2.1 - #removing wrappers....
ruby-2.2.1 - #removing environments....

這里有個(gè) brew doctor
嗯,鍵入終端看看冒出啥鬼玩意

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: /usr/local/bin isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/bin

Warning: /usr/local/Cellar isn't writable.
You should `chown` /usr/local/Cellar

Warning: /usr/local/etc isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/etc

Warning: /usr/local/include isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/include

Warning: /usr/local/lib isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/lib

Warning: /usr/local/lib/pkgconfig isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/lib/pkgconfig

Warning: /usr/local/opt isn't writable.
You should `chown` /usr/local/opt

Warning: /usr/local/share isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/share

Warning: Some directories in /usr/local/share/man aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
directories, then the install will fail during the link step.
You should probably `chown` them:

    /usr/local/share/man
    /usr/local/share/man/man1

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

在這一坨警告文檔里 第一個(gè)就看到了我們的錯(cuò)誤詳解

Warning: /usr/local/bin isn’t writable.

This can happen if you “sudo make install” software that isn’t managed by 
by Homebrew. If a formula tries to write a file to this directory, the 
install will fail during the link step.

總之就是告訴你 問題還是出在 Homebrew 上面,
然而問題還是存在

總結(jié):

  1. 遇到這個(gè)報(bào)錯(cuò) ,試試先安裝下 Homebrew 試試看,
    如果已經(jīng)安裝過了,可以卸載一下重新安裝,

  2. 如果 rvm install 2.0.0 沒有用,
    可以用這段命令代替,好像可以自動(dòng)安裝最新版本的ruby

 $ rvm autolibs read-only # read more here:https://rvm.io/rvm/autolibs
 $ rvm install ruby

問題暫時(shí)先記錄在這里,留以后再來翻閱
這是收集整理網(wǎng)上資料的文字,如有不妥,可以直接聯(lián)系我撤掉.我的郵箱 281090013@qq.com.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末悔耘,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子我擂,更是在濱河造成了極大的恐慌衬以,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,214評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件校摩,死亡現(xiàn)場離奇詭異看峻,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)衙吩,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,307評論 2 382
  • 文/潘曉璐 我一進(jìn)店門互妓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人坤塞,你說我怎么就攤上這事冯勉。” “怎么了摹芙?”我有些...
    開封第一講書人閱讀 152,543評論 0 341
  • 文/不壞的土叔 我叫張陵灼狰,是天一觀的道長。 經(jīng)常有香客問我浮禾,道長交胚,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,221評論 1 279
  • 正文 為了忘掉前任盈电,我火速辦了婚禮蝴簇,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘匆帚。我一直安慰自己熬词,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,224評論 5 371
  • 文/花漫 我一把揭開白布卷扮。 她就那樣靜靜地躺著荡澎,像睡著了一般。 火紅的嫁衣襯著肌膚如雪晤锹。 梳的紋絲不亂的頭發(fā)上摩幔,一...
    開封第一講書人閱讀 49,007評論 1 284
  • 那天,我揣著相機(jī)與錄音鞭铆,去河邊找鬼或衡。 笑死焦影,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的封断。 我是一名探鬼主播斯辰,決...
    沈念sama閱讀 38,313評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼坡疼!你這毒婦竟也來了彬呻?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,956評論 0 259
  • 序言:老撾萬榮一對情侶失蹤柄瑰,失蹤者是張志新(化名)和其女友劉穎臼勉,沒想到半個(gè)月后闸迷,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體漆改,經(jīng)...
    沈念sama閱讀 43,441評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡朱转,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,925評論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了授翻。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片或悲。...
    茶點(diǎn)故事閱讀 38,018評論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖堪唐,靈堂內(nèi)的尸體忽然破棺而出巡语,到底是詐尸還是另有隱情,我是刑警寧澤淮菠,帶...
    沈念sama閱讀 33,685評論 4 322
  • 正文 年R本政府宣布捌臊,位于F島的核電站,受9級特大地震影響兜材,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜逞力,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,234評論 3 307
  • 文/蒙蒙 一曙寡、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧寇荧,春花似錦举庶、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,240評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至峦嗤,卻和暖如春蕊唐,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背烁设。 一陣腳步聲響...
    開封第一講書人閱讀 31,464評論 1 261
  • 我被黑心中介騙來泰國打工替梨, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 45,467評論 2 352
  • 正文 我出身青樓副瀑,卻偏偏與公主長得像弓熏,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子糠睡,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,762評論 2 345

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