美文网首页iOS归纳
CocoaPods安装和使用(macOS)

CocoaPods安装和使用(macOS)

作者: 明天的明天的明天 | 来源:发表于2022-05-05 16:35 被阅读0次

    一、安装Homebrew

    Homebrew是macOS平台下的软件包管理工具,可自行前往https://brew.sh/index_zh-cn了解;安装方法参考https://brew.idayer.com/guide/change-source,下方安装命令平台macOS、终端类型zsh、中科大源(其他类型以及安装过的换源,可前往链接查看);关于终端类型,执行命令echo $SHELL,显示/bin/bash则是bash,显示/bin/zsh则是zsh

    安装命令如下:

    1.执行安装脚本

    export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"

    export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"

    /bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

    2.安装完成后设置

    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile

    source ~/.zprofile

    二、安装GPG

    brew install gnupg

    完成后重启终端

    三、安装RVM(Ruby Version Manager)

    关于RVM以及安装方法参考https://rvm.io/

    1.Install GPG keys:

    gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

    2.Install RVM:

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

    3.For installing RVM with default Ruby and Rails in one command:

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

    四、更新Ruby

    1.查看当前Ruby版本

    ruby --version

    2.查看可安装版本

    rvm list known

    3.选择指定Ruby版本进行更新

    rvm install 3.0.0

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

    rvm use 3.0.0 --default

    五、更换Ruby镜像源

    1.查看当前源

    gem sources -l

    2.移除旧的源

    gem sources --remove https://rubygems.org

    3.添加新源

    gem sources --addhttps://gems.ruby-china.com

    四、安装CocoaPods

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

    五、设置CocoaPods仓库

    参考清华大学开源镜像站https://mirror.tuna.tsinghua.edu.cn/help/CocoaPods/

    cd ~/.cocoapods/repos

    如果出现No such file or directory,可以先用xcode新建一个demo,cd进文件夹执行pod init,然后执行pod install中途control+c中断即刻,再重新执行cd ~/.cocoapods/repos

    pod repo remove master

    git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

    最后进入自己的工程,在自己工程的podFile第一行加上:

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

    相关文章

      网友评论

        本文标题:CocoaPods安装和使用(macOS)

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