美文网首页
iOS 最新安装Cocopods

iOS 最新安装Cocopods

作者: UILable攻城狮 | 来源:发表于2023-09-03 12:19 被阅读0次

    最新安装Cocopods 记录

    安装Cocoapods之前需要安装许多东西,具体流程是这样, Xcode — Homebrew — RVM — Ruby — Cocoapods

    1 安装Xcode 直接去appstore下载安装

    2 安装Homebrew

    /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
    
    • 跟着 流程 一步步走
    • 查看是否成功安装 查看版本
     brew -v   
    
    • 如果出现如下的信息,说明安装成功,可以使用了:
    Homebrew 4.1.7
    

    3 安装RVM

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

    如果报错
    curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

    打开网站:https://www.ipaddress.com/ip-lookup

    查询一下 raw.githubusercontent.com 对应的IP 地址

    替换系统的host文件

    *注意:最好复制一份出来在更改
    步骤 1. 打开/etc/hosts文件,最后一行添加

    185.199.109.133  raw.githubusercontent.com
    

    然后再执行

    curl -sSL https://get.rvm.io | bash -s stable
    
    source ~/.bashrc
    
    source ~/.bash_profile
    

    查看rvm是否安装成功

    rvm -v
    

    rvm安装成功长这样:

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

    4 安装Ruby

    查看已经安装了那些 源

     gem sources -l
    

    移除所有的源

    gem sources --remove + 源名字,下面示例
    gem sources --remove  https://rubygems.org/
    

    添加 清华源, 目前这个用起来我感觉最快

    gem sources -a  https://mirrors.tuna.tsinghua.edu.cn/rubygems/
    

    再次检测 是否成功添加

    gem sources –l
    

    添加成功长这样:

    xxxx@xxxMac ~ % gem sources –l
    *** CURRENT SOURCES ***
    
    https://mirrors.tuna.tsinghua.edu.cn/rubygems/
    

    升级Ruby

    查看一下ruby有哪些版本:

    rvm list known
    

    然后你挑一个版本高的,因为不然执行:会提示版本低 需要大于。。。。。之类的

    rvm install 3.0.0
    

    查看安装后的版本

    ruby -v
    

    ruby安装成功长这样:

    ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin22]
    

    安装cocoaPods

    安装指定版本

    sudo gem install cocoapods -v 1.12.1
    

    这样就成功了

     pod --version
    
    1.12.1
    

    显示隐藏文件

    defaults write com.apple.finder AppleShowAllFiles -boolean true;killall Finder
    

    隐藏文件

    defaults write com.apple.finder AppleShowAllFiles -boolean false;killall Finder
    

    我们需要显示隐藏文件

    • 对于旧版的 CocoaPods 可以使用如下方法使用 tuna 的镜像:
    pod repo remove master // 移除master源
    
    pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git // 添加清华源
    
    pod repo update // 更新资源库
    
    • 新版的 CocoaPods 不允许用pod repo add直接添加master库了,但是依然可以:
    cd ~/.cocoapods/repos // 进入pods资源库
    
    pod repo remove master // 移除master源
    
    git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master // 克隆清华源
    

    最后进入自己的工程,在自己工程的podFile第一行加上(也可以不加 执行pod update操作后 会自动加上):

    source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
    

    最后就可以pod search 或者podinstall 啦

    相关文章

      网友评论

          本文标题:iOS 最新安装Cocopods

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