1 背景
今天,新MacBook Pro到了,开始踩坑之旅。
2 Cocoapods安装错误
安装Cocoapods时,报了如下错误:
sudo gem install cocoapods
错误:
xxxx
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.15.4/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 ./siteconf20211026-2039-14hcvv.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.15.4 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.4/gem_make.out
搜索了一下,大部分人说是没有安装rvm,试了下:
% rvm
zsh: command not found: rvm
果然,没有rvm,那就安装。
\curl -sSL https://get.rvm.io | bash -s stable --ruby
然后又有报错:
xxxxxx
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/12.0/arm64/ruby-3.0.0.tar.bz2
Checking requirements for osx.
About to install Homebrew in the default location `/usr/local`.
It is possible to select a custom location, however it is not recommended and some things might not work.
You should do it only if you do not have write rights to `/usr/local`.
Press ENTER to install Homebrew in the default location `/usr/local`
or type a custom path (needs to be writable for the current user)
: Requirements installation failed with status: 1.
需要安装Homebrew,输了brew版本看一下:
% brew --version
zsh: command not found: brew
果然,brew也没有,那么安装:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装brew会耗费很长的时间,因为要安装Command Line Tools。最后安装好。安装好后,注意最后有一段提示:
HEAD is now at 2b97d295aff vpn-slice: update 0.15_1 bottle.
Updated 1 tap (homebrew/core).
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
==> 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 (or will 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 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/yuhua/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
brew路径没有被添加到PATH中,于是接下来添加到PATH中。
在.zshrc中添加
export PATH="$PATH:/opt/homebrew/bin"
然后关闭终端,再打开,再查看brew版本:
% brew --version
Homebrew 3.3.0
Homebrew/homebrew-core (git revision aace28c018f; last commit 2021-10-26)
可以了,然后再rvm安装命令,安装好后,再执行sudo gem install cocoapods即可。最后查看一下:
% pod --version
1.11.2
网友评论