Mac安装Cocoapods以及Ruby开发环境遇到的问题及解决

首先由于万恶的'墙', 咱们先搭个梯子

0. 请尽可能用比较新的 RubyGems 版本,建议 2.6.x 以上。

$ gem update --system # 这里请翻墙一下$ 

gem -v 查看当前gem版本, 我的是2.6.7

1.移除现有Ruby默认源

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

2.使用新的源

这里要注意, 国内的taobao源已跪, 请使用天朝ruby官方新源

$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

3.验证新源是否替换成功

$ gem sources -l

https://gems.ruby-china.com

# 确保只有 gems.ruby-china.com


4.安装CocoaPods

(1)  $sudo gem install cocoapods 备注:苹果系统升级 OS X EL Capitan 后改为  $sudo gem install -n /usr/local/bin cocoapods

(2)  $pod setup

5.更新gem

$sudo gem update --system


这里要开始注意了!!!

错误1(对于还在使用http的taobao源的童鞋来说):

Error fetchinghttp://ruby.taobao.org/:

bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)

解决方案:把安装流程中 $gem sources -a http://ruby.taobao.org/   ---改为---->  $gem sources -a https://ruby.taobao.org/

错误2:

ERROR:  While executing gem ... (Errno::EPERM)

Operation not permitted - /usr/bin/pod

解决方案:苹果系统升级OS X EL Capitan后会出现的插件错误,将安装流程 4.安装CocoaPods 的 (1)sudo gem install cocoapods ——>改为sudo gem install -n /usr/local/bin cocoapods

错误3:

[!] Unable to satisfy the following requirements:  - `AVOSCloud (~> 3.1.6.3)` required by `Podfile`

Specs satisfying the `AVOSCloud (~> 3.1.6.3)` dependency were found, but they required a higher minimum deployment target.

解决方案:安装流程:Podfile文件 中   platform:ios, ‘7.0’  后边的 6.0 是平台版本号 ,一定要加上

错误4:activesupport requires Ruby version >= 2.2.2.ruby运行环境版本过低 ,升级ruby版本即可

RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gems)

$ curl -L get.rvm.io | bash -s stable

测试是否安装正常

$ source ~/.bashrc

$ source ~/.bash_profile

查看当前rvm版本

$rvm -v

用RVM升级Ruby

查看当前ruby版本

ruby -v

列出可更新的版本列表

$ rvm list known

安装ruby 2.3.0

$ rvm install 2.3.0

出现这样的错误:

Error running '__rvm_make -j 1',showing last 15 lines of /Users/GDarkness/.rvm/log/1474100434_ruby-2.2.4/make.log

先安装xcode command line 即可解决(由于从App Strore上安装的Xcode默认没装command line)

最后再用这个命令验证一下:

$xcode-select --install


出现这个说明已经安装好了, 现在重新执行rvm install 2.3.0命令进行安装即可

安装完毕查看当前安装的ruby:

$ rvm list

将最新版本设为默认ruby环境

$ rvm 2.3.0 --default

最后执行ruby -v 验证一下

最后的最后...有帮你的, 请不要吝啬你的❤️哦

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容