2016最新的CocoPods安装

A.打开终端

 $ ruby -v  #查看ruby的版本

打印代码:

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

B. 更换ruby镜像:

终端输入如下命令(把Ruby镜像指向taobao,避免被墙,你懂得)

a.移除现有 Ruby 默认源输入以下指令

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

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

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

#淘宝源已经停更了目前最新的是
$gem source -a https://gems.ruby-china.org

这里附上官网地址 --> RubyGems 镜像- Ruby China

D.验证新源是否替换成功输入以下指令:

$gem sources -l  #检查源镜像的

E.安装cocoapods

$sudo gem install cocoa pods

这就遇到我的第一个问题:

如果你的ruby 版本过低 就会报错:

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

前几天,我就搞到这个地方,尝试了好几种方法更新ruby 但是都没有成功,今天偶然看到一个文章,你们可以看一下 作者:有种淡淡的忧伤 -->安装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. 执行文件

$ 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查看当前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.

如果安装失败

如果提示以下报错或警告:

解决方法:

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

注意,不一定是报这个错,但是提示会告诉你解决方法,一般是缺少啥,然后提示你用哪个命令安装

第二个问题:

解决方案:


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

Password: (输入电脑权限密码)

$ 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>]

第二个问题就解决了

然后再重新执行:安装2.2.2版本 步骤 就可以解决

1. 查看当前ruby 版本

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

现在ruby版本已经是2.2.2了

第一个问题就解决了

2. 继续安装 CocoaPods

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

3. 更新 gem

$sudo gem update --system

4. 新建一个项目,名字PodTest

5. 跳转到项目路径 $ cd 项目路径 (中间有空格)

cd /Users/lucky/Desktop/PodTest   

6. 建立Podfile(配置文件)

$vim Podfile

键盘输入 i 进入编辑模式,输入 不知道的可以自行百度鸟哥的私房菜.
简单使用可以查看 VIM编辑器的使用

platform :ios, '8.0'

use_frameworks! #//通过指定use_frameworks!要求生成的是framework而不是静态库
inhibit_all_warnings! #//在全局指定不显示所有所引用的库中的警告信息

#这个不清楚的自己上GitHub上面看吧
target 'TestDemo' do

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

end

补充:

回车后反馈如下:

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

提示的信息表示,已经安装好了,如果你想要删掉 就键入如下代码巴拉巴拉“`

并且我再次键入

$rvm install ruby-2.0.0-p643 

依旧报错

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

得了,好好仔细看看报错内容吧 not writable 不可写入, 是不是安装不上啊 然后百度到一条老外也出一样的错误 他是这么解决的
终端命令:

 $ 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

事情并没有这么就结束,我回头再看报错的提示信息

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

当然 首先把安装好的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....

这里有个 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`.

在这一坨警告文档里 第一个就看到了我们的错误详解

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 上面,
然而问题还是存在

总结:

  1. 遇到这个报错 ,试试先安装下 Homebrew 试试看,
    如果已经安装过了,可以卸载一下重新安装,

  2. 如果 rvm install 2.0.0 没有用,
    可以用这段命令代替,好像可以自动安装最新版本的ruby

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

问题暂时先记录在这里,留以后再来翻阅
这是收集整理网上资料的文字,如有不妥,可以直接联系我撤掉.我的邮箱 281090013@qq.com.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,099评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,828评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,540评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,848评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,971评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,132评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,193评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,934评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,376评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,687评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,846评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,537评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,175评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,887评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,134评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,674评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,741评论 2 351

推荐阅读更多精彩内容