美文网首页
Mac 安装cocoapods

Mac 安装cocoapods

作者: 你美依旧 | 来源:发表于2024-03-07 18:09 被阅读0次

    1、查看ruby版本

    ruby -v
    
    ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86 64-darwin21]
    

    iOS 有默认ruby版本(2.6.10),我们需要升级ruby的版本

    2、 安装rvm

    使用命令安装

      git clone https://github.com/rvm/rvm.git
    

    也可以直接去git下载

    541709891102_.pic.jpg

    找到下载地址运行rvm


    551709891313_.pic.jpg

    3、升级ruby版本

    rvm install ruby
    

    错误处理

    Error running '__rvm_make -j16',
    please read /Users/admin/.rvm/log/1709887873_ruby-3.0.0/make.log
    

    3.1 安装1.1版本的OpenSSL

    brew install openssl@1.1
    

    3.2 安装成功后,指定OpenSSL的版本重新执行安装Ruby的命令

    rvm install ruby-3.0.0 --with-openssl-dir='brew --prefix openssl@1.1'
    

    3.3 如果还是报错先执行命令

    brew link --overwrite openssl@1.1
    

    再去执行3.2

    4、安装Homebrew

    /bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh](https://link.zhihu.com/?target=https%3A//gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh))"
    
    1、中科大下载源
    2、清华大学下载源
    3、北京外国语大学下载源
    4、腾讯下载源
    5、阿里巴巴下载源
    序列号选择如:1 中科大
    输入开机密码完成安装
    输入使用源编号如:5 阿里源
    输入: source /Users/wanghui/.zprofile
    
    

    切记,执行完后,需要重启终端。

    5 、查询镜像地址:

    gem sources -l
    

    如果是:https://rubygems.org/,则需要先执行下面的命令来替换掉。

    gem sources --remove https://rubygems.org/
    gem sources -a https://gems.ruby-china.com/
    
    

    6、安装CocoaPods

    sudo gem install -n /usr/local/bin cocoapods
    

    如果出现权限问题,可替换命令为

    sudo gem install cocoapods --user-install
    

    7、pod 调试

    在终端输入pod search AFNetworking指令出现如下错误

    Setup completed
    [!] Unable to find a pod with name, author, summary, or description matching `AFNetworking`
    

    解决方案

    移除/.cocoapods/repos目录下的master文件,然后重新下载即可。
    
    cd ~/.cocoapods/repos
    git clone --depth 1 https://github.com/CocoaPods/Specs.git master
    

    删除搜索记录

    rm ~/Library/Caches/CocoaPods/search_index.json
    

    相关文章

      网友评论

          本文标题:Mac 安装cocoapods

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