Mac安装Cocapods(Apple M1芯片)

首先需要先安装Homebrew

  • 更新完Homebrew之后更新Ruby

使用Homebrew安装Ruby

  • brew install ruby
  • 如果出现fatal,先终止任务(这里等了很久最终也会报错)
fatal: Could not resolve HEAD to a revision
==> Tapping homebrew/cask
Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 605915, done.
remote: Counting objects: 100% (72/72), done.
remote: Compressing objects: 100% (72/72), done.
error: 5414 bytes of body are still expected.31 MiB | 271.00 KiB/s
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: index-pack failed
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-cask /opt/homebrew/Library/Taps/homebrew/homebrew-cask --origin=origin --template=` exited with 128.
  • 参考fatal的解决方法
  • 解决了fatal后,使用brew install ruby安装ruby
  • 安装完成后,终端出现下面的内容说明ruby安装完成
==> Installing ruby
==> Pouring ruby-3.0.2_1.arm64_big_sur.bottle.tar.gz
==> Caveats
By default, binaries installed by gem will be placed into:
  /opt/homebrew/lib/ruby/gems/3.0.0/bin

You may want to add this to your PATH.

ruby is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"

==> Summary
  /opt/homebrew/Cellar/ruby/3.0.2_1: 16,390 files, 40.4MB
==> Caveats
==> ruby
By default, binaries installed by gem will be placed into:
  /opt/homebrew/lib/ruby/gems/3.0.0/bin

You may want to add this to your PATH.

ruby is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"
  • 但是使用ruby -v的时候发现ruby还是之前的版本号
  • 设置ruby的环境变量PATH,在命令行中执行echo的提示信息
    echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
  • 再根据echo的提示信息,使用source ~/.zshrc(不要关闭窗口)
  • 在当前窗口下查看ruby版本如果更新成功就可以安装cocoapods了

安装cocoapods

  • gem install cocoapods
  • 愉快的完成

你可能感兴趣的:(Mac安装Cocapods(Apple M1芯片))