美文网首页
cocoaPod安装

cocoaPod安装

作者: Berning | 来源:发表于2019-10-04 14:09 被阅读0次

    一、安装rvm(ruby version manager)和检查更新ruby

    1. 安装rvm
    • 命令
    $ rvm -v  
    
    • 已安装
    $ rvm -v  
    rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
    
    • 未安装
    $ rvm -v  
    -bash: rvm: command not found
    //$ curl -sSL https://get.rvm.io | bash -s stable   (参考 https://rvm.io)
    $ curl -L https://get.rvm.ip|bash -s stable
    $ rvm -v  
    rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
    
    
    • 开启rvm
    source  /Users/username/.rvm/scripts/rvm 
    
    1. Mac自带ruby,检查ruby环境,现在(2019/8/31)要求ruby环境at least 2.4.4,我的2.3.7
      -rvm查看ruby版本:
    $ rvm list known
    
    • 更新命令:
      (最新版本2.7.0)
    $ rvm install 2.7.0
    

    然后根据提示按:回车-回车-输入密码,等待即可

    二、RubyGems(参考:https://gems.ruby-china.com

    1. 检查更新RubyGems环境
    • 检查
    $ gem -v  //建议2.6.x以上,我的2.5.2.3
    
    • 更新
    $ sudo gem update --system
    
    1. 查看替换RubyGems源
    • 查看
    $ gem sources -l 
    https://rubygems.org/
    
    • 替换
    $ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    

    三、安装cocoapods和使用

    • 安装coacoPods
    $ sudo gem install -n /usr/local/bin cocoapods
    
    • 使用:
    • 新建Xcode项目CocoaPodsTest
    • 进入项目根目录CocoaPodsTest
    • 创建Podfile文件
    pod init
    
    • Podfile配置
    vim Podfile
    
    source 'https://github.com/CocoaPods/Specs.git'
    platform:ios, '8.0'
    target 'CocoaPodsTest' do
     pod 'AFNetworking'  '~>3.0'
    end
    
    • 安装
    pod install
    

    相关文章

      网友评论

          本文标题:cocoaPod安装

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