前两天更新macOS到10.15,Xcode更新到10.3,当时用起来也还挺正常的就没有细管。
昨天朋友让我帮忙pod一个工程,我才发现问题大了
按照惯例输入 $ pod install 之后 出现了这个提示
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
一脸懵逼,发现是更新之后环境出了问题,找不到cocopods了, 需要重新安装
终端输入 :
$ sudo gem update --system
$ sudo gem install -n /usr/local/bin 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.6.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200324-761-1eev932.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.12.2/gem_make.out
查看报错信息,搜索之后发现需要重新安装rvm和ruby的, 环境出现了问题,那接下来就得先安装环境了
- 开始安装rvm
curl -L https://get.[rvm.io](http://rvm.io) | bash -s stable
- 然后再载入rvm环境
source ~/.rvm/scripts/rvm
- 完成后检测rvm版本
rvm -v
- 查询已知ruby环境
rvm list known
- 安装最新ruby (注:不建议安装最新ruby,会有很多问题 我安装的2.4.0版本$ rvm install 2.4.0)
rvm install ruby
又报了一个错误说是Mac上没有安装Homebrew
Something went wrong during Homebrew installation,
can not find 'brew' command, please report a bug: https://github.com/rvm/rvm/issues
Requirements installation failed with status: 1.
- 下载 Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
这个时候你会发现下载速度异常的慢,明显是被限速了,那么按照下面博客的方法修改下载源即可高速下载:
https://www.jianshu.com/p/6b486e12454f
- 更新完成后继续安装ruby,这个时候下载非常慢,没办法只能熬
rvm install ruby
终于下载完成了,检查一下rvm和ruby的版本
% rvm -v
提示如此就是成功:
rvm 1.29.9-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
% ruby -v
提示如此就是成功:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
再检查一下 rvm关联的ruby
%rvm list
提示如此就是成功:
=* ruby-2.7.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
这些步骤完成之就可以成功下载cocoapods了。
解决Cocoapods贼慢问题
CocoaPods 升级新版本问题
还有一个问题就是cocoapods新版本蒋之前的master改为了CDN模式,clone不下来库的话,可以考虑将Podfile里的第一行Source那行删除,再进行pod install,会自动更新成CDN模式。
这次更新遇到的坑就这么多,回回更新回回坑,一坑坑你两三天。
以后还是少更新任何开发工具的版本吧
参考博客 :
https://www.jianshu.com/p/9c9f8d4867eb
https://www.jianshu.com/p/f5591af6859d
http://blog.sina.com.cn/s/blog_bd5ac53b0102wpt5.html
网友评论