美文网首页
CocoaPods安装的相关问题

CocoaPods安装的相关问题

作者: NHLNIOOO | 来源:发表于2020-03-26 12:35 被阅读0次

    几个概念

    • Homebrew:一个软件包管理器,用于在mac上安装一些os x上没有的UNiX工具;类似于360软件管理器。
    • rvm:全称 Ruby Version Manager ,是安装和管理 ruby 的一种工具。
    • ruby:是一种面向对象的脚本语言。
    • CocoaPods:CocoaPods 是用 ruby 实现的,要想使用它首先需要有 ruby 的环境,OS X系统默认已经可以运行 ruby 了。但是有时候 ruby 版本过低是无法正常支持 CocoaPods 的使用,所以需要先安装更新升级 rvm 和 ruby。

    rvm操作

    • 检查rvm环境
    rvm -v
    

    存在的情况

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

    不存在的情况

    -bash: rvm: command not found
    

    这时需要安装homebrew

    curl -L https://get.[rvm.io](http://rvm.io) | bash -s stable
    

    如果安装失败会提示:curl: (7) Failed to connect to >raw.githubusercontent.com port 443: Operation

    解决办法:
    1.打开:>https://raw.githubusercontent.com/Homebrew/install/master/install
    2.把这个网页的内容拷贝一份命名为brew_install.rb放到桌面。
    3.并在终端输入

    curl
    

    4.成功会提示:
    curl: try 'curl --help' or 'curl --manual' for more information
    5.终端进入桌面目录下

    cd Desktop
    

    6.输入一下命令

    ruby brew_install.rb
    

    然后就开始安装homebrew了

    接下来继续安装rvm

    • 开始安装
    curl -L https://get.[rvm.io](http://rvm.io) | bash -s stable
    
    • 载入环境
    source ~/.rvm/scripts/rvm
    
    • 进入目录
    source ~/.bashrc
    source ~/.bash_profile
    
    • 成功后查看版本
    rvm -v
    

    ruby升级

    • 获取ruby版本
    ruby - v
    
    • 对比ruby版本
    rvm list known
    
    • 更新ruby
    rvm install x.x.x-preview1 
    

    或者

    rvm install x.x.x.
    

    更换ruby源

    • 查看当前源
    gem sources -l
    
    • 移除默认源
    gem sources --remove https://ruby.taobao.org/
    
    • 替换源
    gem sources -a https://gems.ruby-china.com/
    

    CocoaPods的安装使用
    安装教程:http://www.code4app.com/article/cocoapods-install-usage

    意外状况

    • [!] Unable to find a specification for CocoaAysncSocket
      或者
    • [!] Unable to find a pod with name, author, summary, or description matching CocoaAysncSocket
     pod setup 
    
    • 还是错误,删除~/Library/Caches/CocoaPods目录下的search_index.json文件
    rm ~/Library/Caches/CocoaPods/search_index.json 
    
    • 常用命令
    pod install --verbose --no-repo-update
    

    解决pod时间很慢,不更新。

    • 更新
    pod update --verbose --no-repo-update
    

    相关文章

      网友评论

          本文标题:CocoaPods安装的相关问题

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