美文网首页iOS成长路线iOS DeveloperiOS开发进阶
安装CocoaPods过程和遇到各种坑(楼主亲测)

安装CocoaPods过程和遇到各种坑(楼主亲测)

作者: 宋唐不送糖 | 来源:发表于2016-07-15 10:25 被阅读5102次

    初次使用简书写文章,格式略乱,轻喷~~~~

    网络不好慎用!!!!

    网络不好慎用!!!!

    网络不好慎用!!!!

    1.打开终端

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

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

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

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

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

    $gem sources -l

    5.安装 CocoaPods 

    $sudo gem install cocoa pods


    //–––––––––––那么问题来了——没遇到的自动跳过————————————

    错误提示1

    Error installing cocoapods:  activesupport requires Ruby version >= 2.2.2.

    解决方案 :

    1、安装 RVM baby 版本管理器 

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

    //________等安装完成 出现下面这行提示以下___________

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

    执行

    $source ~/.bashrc  

    $source ~/.bash_profile  

    测试是否安装正常

    $rvm -v  

    //________提示以下___________

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

    2、用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-headruby-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

    //___________________

    安装ruby 2.2.2 执行

    $rvm install 2.2.2

    干货1:安装ruby遇到" Installing Homebrew - Brew Command Not Found"命令找不到解决方案:

    Check XCode is installed or not.

    $gcc --version

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

    $brew doctor

    $brew update.

    完成后 执行

    $ruby -v

    //–––––打印输出–––––––

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


    6 继续安装 CocoaPods

    $sudo gem install cocoa pods

    //______安装成功提示如下______

    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 21 seconds,23 gems installed

    $pod setup

    备注:苹果系统升级 OS X EL Capitan 后安装改为:

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

    $pod setup

    干货2:CocoaPods无限卡在Setting up CocoaPods master repo解决方案:

    对于初次使用CocoaPods的同学,即使你不使用pod setup命令,在你初次执行pod install命令时,系统也会自动执行pod setup。而由于网络不稳定的原因,不挂VPN是不可能成功执行pod setup的。(我大天朝的墙啊~~~~)

    $ pod repo remove master

    $ git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master

    $ pod repo update

    7 更新 gem

    $sudo gem update --system

    8 新建工程,并在终端用 cd 指令到文件夹内

    $pod search 第三方

    9 新建 Podfile 文件

    $ touch Podfile

    10 编辑 Podfile 文件,并写入要添加的第三方库(cocoapod1.0.1版本Podfile文件的内容格式要求发生了变化,必须指出指出所用第三方库的target)

    platform:ios, '8.0'

    #use_frameworks!个别需要用到它,比如reactiveCocoa

    target 'XXXApp' do

    pod 'AFNetworking', '~> 2.3.1'<-------第三方

    end

    11 导入第三方库

    $pod install --no-repo-update

    12 退出终端

    相关文章

      网友评论

      • 陨之希留leo:第二步 sudo gem sources -a https://ruby.taobao.org/的时候就提示
        ERROR: While executing gem ... (Gem::Exception)
        Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
        ps:本人没有用RVM baby 版本管理器
      • HelloDarry:真的是纯干货!
        宋唐不送糖:@HelloDarry :smile: 谢谢,最近几个月比较忙所以有些也没及时看到
      • a12db9d76464:/Users/haibocai/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'cocoapods' (>= 0.a) among 10 total gem(s) (Gem::MissingSpecError)
        Checked in 'GEM_PATH=/Users/haibocai/.rvm/gems/ruby-2.3.0:/Users/haibocai/.rvm/gems/ruby-2.3.0@global', execute `gem env` for more information
        from /Users/haibocai/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:320:in `to_spec'
        from /Users/haibocai/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
        from /usr/local/bin/pod:22:in `<main>'

        老是卡在这一步,请问大神是什么原因啊
        宋唐不送糖:@a12db9d76464 http://www.cnblogs.com/kw-ios/p/3831301.html 搬来大神文章
      • 我是陌路人:用rvm安装的
        $ ruby -v
        ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin16]
        然后运行sudo gem install cocoa pods 提示
        ERROR: While executing gem ... (Gem::Exception)
        Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
        求解答
        宋唐不送糖:@我是陌路人
        yum -y install openssl-devel
        yum -y install openssl
        进入ruby 源码目录下的ext/openssl 目录:

        cd /usr/local/src/ruby-2.2.3/ext/openssl/
        执行 ruby ./extconf.rb :

        [root@server openssl]# ruby extconf.rb
        checking for t_open() in -lnsl... no
        checking for socket() in -lsocket... no
        checking for assert.h... yes
        checking for openssl/ssl.h... yes
        ..........................................................................中间略..........................................................................
        checking for EVP_CTRL_GCM_GET_TAG in openssl/evp.h... yes
        creating extconf.h
        creating Makefile
        将ruby 源码目录下的include 目录软链接到 / 目录下:

        [root@server openssl]# ln -s /usr/local/src/ruby-2.2.3/include /
        编译安装:

        make && make install
        然后就好了!

        再运行:

        gem install redis
        即可正常运行!!
      • 我爱荔枝吃:我的安装完以后
        CocoaPods 1.1.0.rc.2 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.rc.2

        Setup completed
        出来了这些东西是怎么回事可以了吗
      • 8ce8364bdfbc:zhangyudeMacBook-Pro:~ zhangyu$ curl -L get.rvm.io | bash -s stable
        % Total % Received % Xferd Average Speed Time Time Time Current
        Dload Upload Total Spent Left Speed
        100 184 100 184 0 0 239 0 --:--:-- --:--:-- --:--:-- 239
        100 22865 100 22865 0 0 5158 0 0:00:04 0:00:04 --:--:-- 10709
        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

        我安装rvm的时候无限卡在这个地方了,请问大神是什么原因啊
      • llllllllIllllIl: $sudo gem install cocoapods 备注:苹果系统升级 OS X EL Capitan 后改为 $sudo gem install -n /usr/local/bin cocoa pods。我的系统是os x el capitan,我已经安装好了,可以用了,但是回过头来整理的时候发现这条,我当时没有敲后面的代码,有问题吗楼主,请指教。
        宋唐不送糖:@llllllllllll511 这个问题在stack overflow上出现过:Can not perform pod install under el capitan (15A279b)。具体原因的话我也不太清楚 :joy:
      • 跳跳虾:Unable to pull data from 'https://ruby.taobao.org/': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://ruby.taobao.org/specs.4.8.gz)

        楼主 这是什么情况
        跳跳虾:@有种淡淡的忧伤 应该是,突然就成功了,
        宋唐不送糖:@LiuWenqiang 网络问题吗
        跳跳虾:@LiuWenqiang 搞好了, :stuck_out_tongue_closed_eyes:
      • 8fe80d3b30e6:楼主,再用你的干货2的时候又出现了问题:
        [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master

        Cloning into 'master'...
        error: RPC failed; curl 56 SSLRead() return error -9806
        fatal: The remote end hung up unexpectedly
        fatal: early EOF
        fatal: index-pack failed
        这是什么情况
        宋唐不送糖:@TanAres 是的,我这里也是试了3次才成功的,估计你那边网络不太稳定
        8fe80d3b30e6:下了好多次了,都是这样
        宋唐不送糖:@TanAres 网络问题。。。。
      • HuLL乐乐:大神写的不错 成功的帮了我
        宋唐不送糖:@HuLL乐乐 新手新手,有问题大家互相探讨 :smirk:
      • 8fe80d3b30e6:楼主 升级ruby 2.2.2是报错
        Searching for binary rubies, this might take some time.
        No binary rubies available for: osx/10.11/x86_64/ruby-2.2.2.
        Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
        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)
        :
        求解
        宋唐不送糖:@笨鸟晚飞 估计Mac未安装Homebrew造成的,按照我上面的干货1步骤试试
        宋唐不送糖:@TanAres 估计Mac未安装Homebrew造成的,按照我上面的干货1步骤试试
        笨鸟晚飞:@TanAres 我也是遇到像你一样的问题,你找到解决办法了吗,我着搞了好久还没搞出来
      • minjing_lin:求解 黑苹果遇到的问题 http://code4app.com/forum.php?mod=viewthread&tid=9946&page=1#pid213898
        宋唐不送糖:@MinJing_Lin 这个目测网络可能,黑苹果不稳定因素太多表示没用过的 :joy:
      • _何远宛遠坤:选个网络给力的时段..终于搞定...
        宋唐不送糖:@_何远宛遠坤 万恶的网络 :smirk:
      • ea44b28b8ca7:ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
        Unable to download data from https://ruby.taobao.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://ruby.taobao.org/specs.4.8.gz)
        ea44b28b8ca7:@ea44b28b8ca7 我的联系方式企鹅号:647898002
        ea44b28b8ca7:@ea44b28b8ca7 能不能留个联系方式给我,今天装了一下午还是不对 :sob:
        ea44b28b8ca7:@ea44b28b8ca7 sudo gem install -n /usr/local/bin cocoa pods 输入这个错误
      • ea44b28b8ca7:ERROR: Error installing cocoapods:
        activesupport requires Ruby version >= 2.2.2.
        localhost:~ zzz$ $curl -L get.rvm.io | bash -s stable
        -bash: -L: command not found
        localhost:~ zzz$
        宋唐不送糖:@ea44b28b8ca7 ruby -e "$(wget -qO - 'https://raw.github.com/mxcl/homebrew/go')" 这条试试
        ea44b28b8ca7:@ea44b28b8ca7 这个怎么解决啊

      • ea44b28b8ca7:/Users/zzz/Desktop/屏幕快照 2016-07-28 12.03.18.png
      • shenhuniurou:我是前天遇到这个问题,google也没解决问题,今天看到你的文章,解决了。感谢 :smile:
        宋唐不送糖:@新仔007 不客气,我的文章也是转载的,服务大家嘛,哈哈
      • 跳跳虾: 大神 更新成功了,非常感谢 :smile:
        宋唐不送糖:@LiuWenqiang 我也是新手,有问题大家互相探讨嘛,哈哈 :smirk:
      • 跳跳虾:楼主,为什么我的安装完ruby2.2.2 后 失败了,
        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版本 还是之前的2.0.0版本???
        宋唐不送糖:@LiuWenqiang 切换达到另外一个环境
        $ 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>]
        跳跳虾:@有种淡淡的忧伤 报错了,就是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.
        宋唐不送糖:@LiuWenqiang 说明2.2.2没有安装成功。用RVM升级Ruby的时候报错的吗?

      本文标题:安装CocoaPods过程和遇到各种坑(楼主亲测)

      本文链接:https://www.haomeiwen.com/subject/zelyjttx.html