在Mac上安装CocoaPods需要使用Ruby,请按照以下步骤操作:
- 安装rvm,这是 Ruby Version Manager 的缩写,它是一个命令行工具,用于安装不同版本的 Ruby。打开终端并输入以下命令:$ curl -L https://get.rvm.io | bash -s stable
jishaofngdeiMac:~ dongda$ curl -L https://get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 126 0 0:00:01 0:00:01 --:--:-- 126
100 24532 100 24532 0 0 6681 0 0:00:03 0:00:03 --:--:-- 19736
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
curl: (92) HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
Could not download 'https://github.com/rvm/rvm/archive/1.29.12.tar.gz'.
curl returned status '92'.
Downloading https://bitbucket.org/mpapis/rvm/get/1.29.12.tar.gz
Downloading https://bitbucket.org/mpapis/rvm/downloads/1.29.12.tar.gz.asc
Found PGP signature at: 'https://bitbucket.org/mpapis/rvm/downloads/1.29.12.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Installing RVM to /Users/dongda/.rvm/
Adding rvm PATH line to /Users/dongda/.profile /Users/dongda/.mkshrc /Users/dongda/.bashrc /Users/dongda/.zshrc.
Adding rvm loading line to /Users/dongda/.profile /Users/dongda/.bash_profile /Users/dongda/.zlogin.
Installation of RVM in /Users/dongda/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/dongda/.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
如果有网络问题的话,你可以使用下如下命令:
curl --proxy http://127.0.0.1:19180 -L https://get.rvm.io | bash -s stable
- 执行source命令,让rvm生效
source /Users/dongda/.rvm/scripts/rvm
- 安装home-brew,这个非常简单,参考:https://brew.sh/index_zh-cn,实际就一行命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
在这个过程中可能会遇到下面这个问题:
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly before end of the underlying stream
error: 7532 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
解决方法:https://blog.csdn.net/qcx321/article/details/126013303
但是,之后还有问题,最后改用镜像地址:
/bin/bash -c "$(curl -fsSL https://raw.staticdn.net/Homebrew/install/HEAD/install.sh)"
安装成功之后提示如下:文章来源:https://www.toymoban.com/news/detail-506319.html
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/dongda/.bash_profile
eval "$(/usr/local/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
- 最后再执行安装cocoapods
sudo gem install cocoapods
安装前需要确保下ruby是最新版本:文章来源地址https://www.toymoban.com/news/detail-506319.html
192:~ dongda$ ruby --version
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin21]
# 安装最新ruby版本
192:~ dongda$ rvm install ruby --latest
到了这里,关于最新Mac上如何安装pod的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!