美文网首页
Mac 搭建多个Cocoapods版本共存

Mac 搭建多个Cocoapods版本共存

作者: lsj980Ya | 来源:发表于2021-10-30 13:25 被阅读0次

    1 给系统自带的Ruby版本(System) 安装Cocoapods

    2 Rvm 安装并管理多个版本Ruby

    1、安装Rvm

    curl -sSL https://get.rvm.io | bash -s stable
    

    如果报错curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused 链接不到服务器

    在 /etc/host 文件夹下添加

    199.232.28.133 raw.githubusercontent.com
    

    查看是否安装成功

    ~ ➤ rvm -v
    rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
    

    查看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[.10]
    [ruby-]2.2[.10]
    [ruby-]2.3[.8]
    [ruby-]2.4[.10]
    [ruby-]2.5[.8]
    [ruby-]2.6[.6]
    [ruby-]2.7[.2]
    [ruby-]3[.0.0]
    

    3 安装 指定版本ruby-2.7.2

    rvm install 2.7.2
    

    如果报错 Searching for binary rubies, this might take some time No binary rubies available for: osx/10.11/x86_64/ruby-2.2.4. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for osx. Installing requirements for osx. Updating system....... Error running 'requirements_osx_brew_update_system ruby-2.2.4',

    #执行
    rvm autolibs read-only
    

    继续安装Ruby

    rvm install 2.7.2
    

    4 安装Cocoapods

    把Ruby切换到刚下载的版本

    # 把Ruby切换到刚下载的版本
    rvm use 2.7.2
    # 按照之前的逻辑正常安装Cocoapods
    sudo gem install -n /usr/local/bin cocoapods
    pod setup
    

    此时Mac上已经同时存在了两个Cocoapods版本
    1 一个是系统自带Ruby版本下安装的Cocoapods
    2 另一个是Rvm管理下的Ruby版本下的Cocoapods
    如果想安装多个Cocoapods,只需重复3,4步骤就可以了,一个Ruby版本下可以安装一个Cocoapods环境

    相关文章

      网友评论

          本文标题:Mac 搭建多个Cocoapods版本共存

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