cocoa pods的安装与使用

来源:互联网 发布:淘宝商城客服 编辑:程序博客网 时间:2024/05/22 06:32

正确的安装顺序:

1.安装home-brew

2.安装ruby

3.安装rvm

4.安装cocoa pods.


1.打开终端

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

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

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

gem sources -a https://gems.ruby-china.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 <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

//___________________

2、用RVM升级Ruby

  • 查看当前ruby版本 执行   

    ruby -v 
    列出已知的ruby版本  执行
    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


    # 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

    完成后 执行

    ruby -v

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

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

    //––––––––––––

    当出现Error running 'requirements_osx_brew_update_system bury-2.0.0-p643'时则要先去更新home-brew,因为你的电脑可能没有安装home-brew。

    https://gems.ruby-china.org

    Homebrew官网:http://brew.sh/index_zh-cn.html

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


    然后再次执行:
        $ rvm install 2.0.0



    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

    7.更新 gem

     sudo gem update --system

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

     pod init   这个时候会在目标文件夹内生成一个podfile

    $ touch Podfile

    9.编辑 Podfile 文件,并写入要添加的第三方库

    platform:ios, '8.0'

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

    或直接在终端采用命令的方式编辑podfile :

    1)打开podfile

    vim podfile 

    2)输入i编辑

    pod 'AFNetworking'

    3)按esc退出编辑

    4)输入:wq保存并退出编辑


    10.导入第三方库

    pod update 或pod setup 效果差不多

    11.退出终端


  • 0 0
    原创粉丝点击