美文网首页cocoapods
[Cocoapods] - Cocoapods安装方法 x86

[Cocoapods] - Cocoapods安装方法 x86

作者: AlwaysLuckyMa | 来源:发表于2021-05-01 13:00 被阅读0次

    首先打开终端

    1.安装Homebrew

    /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
    

    2.安装rvm

    curl -L get.rvm.io | bash -s stable 
    source ~/.bashrc
    source ~/.bash_profile
    

    报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connectio

    查询真实IP 通过IPAddress.com首页,输入raw.githubusercontent.com 查询到真实IP地址

    2.1 修改hosts

    sudo vi /etc/hosts 打开hosts
    i 插入
    esc 退出
    : wq 保存

    打开hosts

    3.更新系统上的ruby

    rvm install 2.6.3
    

    这里我直接安装的是2.6.3版本,如果你想安装其他版本,也可先使用

    rvm list known
    

    列出可安装的版本,然后用install命令安装

    4.将刚刚安装的ruby设置为默认版本

    rvm use 2.6.3 --default
    

    5.更换ruby镜像源

    sudo gem update --system
    gem sources --remove https://rubygems.org/
    gem sources --add https://gems.ruby-china.com/
    

    可以使用

    gem sources -l
    

    来看是否更换成功

    6.安装CocoaPods

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

    7.clone CocoaPods仓库

    这里使用的是清华大学fork的CocoaPods仓库

    git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git  ~/.cocoapods/repos/trunk
    

    也可以用gitee上的私人仓库,这个是我自己的,如果更新过慢可以看我这个 [Cocoapods] - 更新 Cocoapods 库如何解决 pod setup 过慢的问题

    https://gitee.com/satoshi_uma/master
    

    上面两个CocoaPods仓库选择一个clone就行了

    到这里CocoaPods已经安装完成了,可以使用

    pod search AFNetworking
    

    来检查是否能正常使用

    *如果你是M1芯片的Mac,还需要做以下操作:

    1.访达-应用程序-实用工具里,右键点击终端-显示简介 (如果找不到实用工具,请以列表或分栏的方式显示项目)
    2.勾选使用Rosetta打开
    3.执行sudo gem install ffi

    附:
    1.Homebrew官方镜像地址

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    2.CocoaPods官方repo地址

    git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
    

    原作者连接:https://www.jianshu.com/p/5d58a42a72d6

    相关文章

      网友评论

        本文标题:[Cocoapods] - Cocoapods安装方法 x86

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