美文网首页iOS相关技术
Cocoapods环境配置

Cocoapods环境配置

作者: 转岗做JAVA | 来源:发表于2019-05-16 23:50 被阅读0次

请按照第一篇文章知识预热配置好ruby和gem。这里我们不使用homebrew安装cocoapods。

  • 安装cocoapods
    sudo gem install -n /usr/local/bin cocoapods
  • 修改cocoapods源提速
对于旧版的 CocoaPods 可以使用如下方法使用国内的的镜像(以清华的镜像为例):
pod repo remove 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 
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'
  • 重置为官方源
    按照上面👆的步骤执行,不过需要把https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git替换成https://github.com/CocoaPods/Specs.git
  • 查找目前版本的pod路径
    which pod
  • 查看资源库列表
    pod repo list

如果上述替换源之后发现执行pod命令时还是使用的官方源,此时可以使用此命令看本地的master源是否是替换后的源。

  • 查看版本
    pod --version
  • 更新cocoapods
    第一步升级gem:sudo gem update -n /usr/local/bin --system
    第二步执行安装操作:sudo gem install -n /usr/local/bin cocoapods
  • 卸载cocopods
sudo gem uninstall cocoapods
查看本地cocopods残留
gem list --local | grep cocoapods
然后使用命令逐个删除
sudo gem uninstall xxx(控制台打印出的残留项)
如果怕删不干净有残留的话可以找到 .cocopods 文件(隐藏文件)删掉就好

参考资料:
cocoapods国内镜像
cocopods彻底卸载重新安装

相关文章

网友评论

    本文标题:Cocoapods环境配置

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