电脑系统升级之后,cocopods使用一直报错,网上找了很多方法,总会又报另外的错误,所以想着彻底删除cocoapods,重新安装,问题解决,虽然简单粗暴,但也算一种方法吧 !
卸载老版本cocopods
$ sudo gem uninstall cocoapods-
查看本地安装过的cocopods相关东西
gem list --local | grep cocoapods
我的显示如下:
cocoapods-core (1.9.1)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.3.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.4.1)
cocoapods-try (1.1.0)然后使用命令逐个删除
$ sudo gem uninstall cocoapods-core如果怕删不干净有残留的话可以找到 .cocopods 文件(隐藏文件)删掉就好快捷键command + shift + .
-
删除完之后接下来安装RVM(如果以前安装过的话需要找到.rvm然后删掉 和.cocopods同理)
$ curl -L https://get.rvm.io | bash -s stable然后,载入 RVM 环境
$ source ~/.rvm/scripts/rvm检查一下是否安装正确
$ rvm -vrvm 1.29.10 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
-
用RVM安装Ruby环境
PS:安装ruby前务必先安装Homebrew
https://brew.sh 官网地址找安装命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"可以先查询已经安装的ruby
$ rvm list如果有安装过,则先卸载已安装版本
$ rvm remove 1.9.2列出已知的ruby版本
$ rvm list knownMRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.9]
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head安装成功之后,开始安装ruby
$ rvm install 2.6.5(看自己需要安装对应版本即可)如果出现错误:Error running 'requirements_osx_brew_libs_install zlib',
please read /Users/liuhongmei1/.rvm/log/1586843983_ruby-2.6.5/package_install_zlib.log
Requirements installation failed with status: 1.
则先执行命令:$ rvm autolibs read-only 之后再安装ruby完成之后检测是否正确
$ ruby -v -
安装cocoapods
$ sudo gem install cocoapods 差不多过个几十秒吧git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master)
Terminal会停留在 Setting up CocoaPods master repo 这个状态一段时间,是因为要进行下载安装,而且 目录比较大,需要耐心等待一下