时间: 2020-08-30|tag: 23次围观|0 条评论

最近用的好好地cocoapods突然出了问题!!!记录一下
在执行pod update时,报以下的错!

[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

原因咱就不追究了,总之最后通过升级cocoapods后成功了!

升级命令

1.查看当前 Cocoapods版本

pod --version

2.检查当前 ruby 源

gem source -l

注意使用gems.ruby-china.com 源,若不是该ruby源可执行以下命令

gem sources --remove 旧源gem sources -a 新源

3.更新Cocoapods

sudo gem install cocoapods

结果这里我直接报

Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200325-10298-1c0azuc.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out

那根据他的提示我们可以知道:

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
这里提示无法获取到ruby的头文件。

解决方法

1.ruby

根据安装错误的提示,我查看了自己Mac的环境,首先检查了自己是否有安装ruby,终端命令行输入ruby -v即可

ruby -v

ruby 2.3.7p456 (2018-03-28 revision 63024)
显示安装的ruby版本

2.rvm

查看rvm版本

rvm-v
升级cocoapods踩坑插图
image.png

发现自己没安装,那就安装吧

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

进入RVM 环境。

source ~/.rvm/scripts/rvm

查看rvm版本

rvm -v
升级cocoapods踩坑插图1
image.png

然后在rvm环境中查询已经安装的ruby,即输入指令:rvm list

rvm list
升级cocoapods踩坑插图2
image.png

发现rvm路径下里并没有ruby环境,至于为什么明明之前查找可以看到有安装,但现在却没有的问题,先不管他先,既然没有安装那咱就安装上,我这里先选择安装的是ruby2.6

rvm install 2.6

等待过后,又给抛出了问题
Error: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
xcode-select --install
Requirements installation failed with status: 1.
这是提示没有安装Command Line Tools,接着安装Command Line Tools

xcode-select --install

确保安装成功:

xcode-select -p
升级cocoapods踩坑插图3
image.png

接着咱再重新执行

rvm install 2.6
升级cocoapods踩坑插图4
image.png

安装成功后再查看下rvm list

rvm list
升级cocoapods踩坑插图5
image.png

可以看到已经有ruby环境了,接下来只要再更新cocoapos即可

sudo gem install cocoapods

更新之后的updata就成功了

文章转载于:https://www.jianshu.com/p/cd8b622c5bfb

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《升级cocoapods踩坑
   

还没有人抢沙发呢~