1.打开终端

终端输入  $ruby -v  查看ruby的版本

打印代码:

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

2. 更换ruby镜像

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

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

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

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

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

淘宝的寒就没有维护了,可能不能使用,可以尝试下面的镜像源(官方推荐)

gem source -a https://gems.ruby-china.org/

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

$gem sources -l  (用来检查使用替换镜像位置成功)

打印代码:

bogon:~ LiuWenqiang$ gem sources --remove https://rubygems.org/
source https://rubygems.org/ not present in cache
bogon:~ LiuWenqiang$ gem sources -a https://ruby.taobao.org/
source https://ruby.taobao.org/ already present in the cache
bogon:~ LiuWenqiang$ gem sources -l
*** CURRENT SOURCES ***

3.安装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 但是都没有成功,今天偶然看到一个文章,(有种淡淡的忧伤http://www.jianshu.com/p/ad98a3364803

)并得到作者的帮助,才得以解决

解决方案:

(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.

如果安装失败

第二个问题:

  解决方案:

$ 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版本 步骤 就可以解决

(5)查看当前ruby 版本

$ruby -v

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

现在ruby版本已经是2.2.2了

第一个问题就解决了

4.  继续安装 CocoaPods

$sudo gem install cocoa pods

$sudo gem install -n /usr/local/bin cocoapods

$pod setup

5.  更新 gem

$sudo gem update --system

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

7.    $ cd  项目路径 (中间有空格,)

    cd /Users/lucky/Desktop/PodTest   

8.   建立Podfile(配置文件)

$vim Podfile

键盘输入 i 进入编辑模式,输入

platform :ios, '7.0'

pod 'MBProgressHUD', '~> 0.8’ (之前的,我的电脑上已经无效了,报错: [!] The dependency `MBProgressHUD (~> 0.8)` is not used in any concrete target.)

(现在使用:MyApp 替换成自己的项目名)

target 'MyApp' do

pod 'AFNetworking', '~> 2.6'

pod 'ORStackView', '~> 3.0'

end

然后按Esc,并且输入“ :”号进入vim命令模式,然后在冒号后边输入wq

再输入  $pod install

注意:现在打开项目不是点击 PodTest.xodeproj了,而是点击 PodTest.xcworkspace

为了确定AFNetworking是否支持CocoaPods,可以用CocoaPods的搜索功能验证一下。在终端中输入:

$ pod search AFNetworking

(文中的$ 符号 是表示在终端输入的意思,符号本身不用添加终端)

参考资料来源:(谢谢这些作者)

http://blog.csdn.net/showhilllee/article/details/38398119

http://blog.csdn.net/zhaojinqiang12/article/details/51682191

cocoa pods 安装 转载的更多相关文章

  1. 安装cocoa pods时出现Operation not permitted - /usr/bin/xcodeproj的问题

    安装cocoa pods时, 在命令行中输入: 安装:sudo gem install cocoapods报Operation not permitted - /usr/bin/xcodeproj这个 ...

  2. 关于IOS新手在安装cocoa pods失败,因为ruby版本过低的解决方法+ (void) {升级ruby}

    http://blog.csdn.net/zhaoen95/article/details/51995520     现在: 使用 OS 系统, 正在学习iOS 需要配置cocoapods 命令行中显 ...

  3. Cocoa pods的安装和使用

    现在网上关于cocoapods的安装使用资料有很多,有些方法能用,有些是用不了的,别问为什么,因为我就是从坑里走出来的.在此自己整理了一些方法: 一般需要先升级Ruby环境: 第一步:安装rvm $  ...

  4. cocoa pods

    # cocoa pods * `CocoaPods` 是 iOS 最常用最有名的类库管理工具 * 作为 iOS 程序员,掌握 `CocoaPods` 的使用是必不可少的基本技能 ## pod 命令汇总 ...

  5. 升级到 OS EI 后 cocoa pods

    安装: sudo gem install -n /usr/local/bin cocoapods 如果出现:pod :command not found 解决办法 S1:cd /Library/Rub ...

  6. cocoa pods 升级遇到的问题

    1. cocoa pods 升级遇到的问题 运行 sudo gem update --system 报错 Updating rubygems-update ERROR: While executing ...

  7. ios --转载 在mac上安装让rvm及cocoa pods详解

    先安装rvm: 打开终端: $ curl -L https://get.rvm.io | bash -s stable (期间可能会问你sudo管理员密码,以及自动通过homebrew安装依赖包,等待 ...

  8. Cocoa Pods的安装

    CocoaPods是用Ruby实现的,要想使用它首先需要有Ruby的环境.幸运的是OS X系统默认已经可以运行Ruby了,因此我们只需执行以下命令: sudo gem install -n /usr/ ...

  9. 安装cocoa pods

    1.移除现有Ruby默认源 $gem sources --remove https://rubygems.org/ 2.使用新的源 $gem sources -a https://ruby.taoba ...

随机推荐

  1. poj1127 Jack Straws(线段相交+并查集)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Jack Straws Time Limit: 1000MS   Memory L ...

  2. php——会话控制

    1.什么叫做会话控制 允许服务器根据客户端做出的连续请求. 2.为什么需要会话控制? 因为当你打开一个网站,并想访问该网站的其他页面的时候,如果没有会话控制,当跳转到其他页面的 时候,就需要再次输入账 ...

  3. json_encode如何防止汉字转义成unicode

    众所周知,json_encode通常会把json中的汉字转义成unicode,但是这并不一定是我们想要的.有时候,我们需要获得汉字形式的json字符串,比如需要获得gbk编码的json字符串(只要把汉 ...

  4. [转载]css3属性box-sizing:border-box的作用

    http://jastate.com/css3-properties-box-sizingborder-box.html 定义和用法 按照w3c school的说法,box-sizing:border ...

  5. iOS学习之数据解析

    解析:按照约定好的格式提取数据的过程叫做解析; 后台开发人员按照约定好的格式存入数据,前端开发人员按照约定的格式读取数据; 主流的格式: XML / JSON 前端和后台都能识别的格式;  XML解析 ...

  6. iOS 两种方法实现左右滑动出现侧边菜单栏 slide view

      现在很多的APP中都有slide view,左右滑动出现侧边菜单栏的功能,Weico这个应用就有. 网上有很多第三方的类库实现了这种效果,其实自己代码写的话也是很简单的,下面我将介绍两种方法实现s ...

  7. hdu 畅通工程

    http://acm.hdu.edu.cn/showproblem.php?pid=1863 #include <cstdio> #include <cstring> #inc ...

  8. UART与USART的区别

    UART与USART都是单片机上的串口通信,他们之间的区别如下: 首先从名字上看: UART:universal asynchronous receiver and transmitter通用异步收/ ...

  9. pywin32 安装错误 ImportError: DLL load failed: 不是有效的 Win32 应用程序

    pywin32 安装错误 ImportError: DLL load failed:  不是有效的 Win32 应用程序. 发现是因为没有制定Pywin32的dll所致,我们在用Pywin32开发时, ...

  10. jQuery ajax方法在Chrome浏览器下失效问题

    最近做测试时碰到一个问题,chrome下使用ajax的一些方法(如get,load等)的时候完全失效: $(function() { $("#send").click(functi ...