mac系统版本:10.15.5 (19F101)
最优解安装顺序:Xcode > HomeBrew > RVM > Ruby > CocoaPods
1. 安装方案1(百度常用法)
1.1 更新gems和换国产源:
RubyGems 镜像 - Ruby Chinahttps://gems.ruby-china.com
1.2 执行
sudo gem install -n /usr/local/bin cocoapods
报错:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
/Library/Ruby/Site/2.6.0/rubygems/installer.rb:712:in `verify_gem_home'
/Library/Ruby/Site/2.6.0/rubygems/installer.rb:902:in `pre_install_checks'
......
网上说是ruby问题, 那么安装ruby管理工具rvm(RVM: Ruby Version Manager - RVM Ruby Version Manager - Documentation)
以下是参照官网文档步骤执行记录,仅供参考,因为软件更新快,请多阅读官网,按照官网来安装才能更好的避坑!
1.2.1 安装key:
//key复制官网最新变更,我这个是当前文档发布时还能用的key
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
1.2.2 安装rvm
\curl -sSL https://get.rvm.io | bash -s stable
报错:
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443
解决办法:
// 清除代理
git config --global --unset http.proxy
再次执行1.2.1, 成功:
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: 签名建立于 六 1/16 02:46:22 2021 CST
gpg: 使用 RSA 密钥 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: 完好的签名,来自于 “Piotr Kuczynski <piotr.kuczynski@gmail.com>” [未知]
gpg: 警告:此密钥未被受信任签名认证!
gpg: 没有证据表明此签名属于其声称的所有者。
主密钥指纹: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/Users/apple/.rvm/archives/rvm-1.29.12.tgz'
Installing RVM to /Users/apple/.rvm/
Adding rvm PATH line to /Users/apple/.profile /Users/apple/.mkshrc /Users/apple/.bashrc /Users/apple/.zshrc.
Adding rvm loading line to /Users/apple/.profile /Users/apple/.bash_profile /Users/apple/.zlogin.
Installation of RVM in /Users/apple/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/apple/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
执行
// 刷新缓存
source ~/.rvm/scripts/rvm
输入rvm -v就有数据了
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
最后重新执行1.2步骤, 安装CocoaPods
2. 安装方案2
安装Homebrew
// 推荐中科源
/bin/zsh -c “$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)”
brew install cocoapods
Warning: You are using macOS 10.15.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from MacHomebrew on Twitter.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.==> Fetching cocoapods
==> Downloading https://github.com/CocoaPods/CocoaPods/commit/2af8ba7e3477296d97
################################################ 100.0%
==> Downloading https://github.com/CocoaPods/CocoaPods/archive/1.11.3.tar.gz
-=O=- # # ##
Warning: Your Xcode (11.2.1) is outdated.
Please update to Xcode 12.4 (or delete it).
Xcode can be updated from the App Store.==> Patching
==> Applying 2af8ba7e3477296d975243eeb1c12f379ab556a1.patch
patching file lib/cocoapods/target/build_settings.rb
==> gem build cocoapods.gemspec
==> gem install cocoapods-1.11.3.gem🍺 /usr/local/Cellar/cocoapods/1.11.3_1: 14,682 files, 30.3MB, built in 23 minutes 19 seconds
==> Running `brew cleanup cocoapods`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
安装Homebrew成功后,用brew命令安装cocoapods
brew install cocoapods
参考:
-bash: rvm: command not found之刨根问底_sundaysme的博客-CSDN博客_-bash: rvm: 未找到命令