2021.10.26新款MacBook Pro m1 pro芯片安裝Cocoapods記錄

1 背景

今天,新MacBook Pro到了,開始踩坑之旅。

2 Cocoapods安裝錯(cuò)誤

安裝Cocoapods時(shí),報(bào)了如下錯(cuò)誤:

sudo gem install cocoapods
錯(cuò)誤:
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

然后又有報(bào)錯(cuò):

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會(huì)耗費(fèi)很長(zhǎng)的時(shí)間,因?yàn)橐惭bCommand 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路徑?jīng)]有被添加到PATH中,于是接下來添加到PATH中。

在.zshrc中添加
export PATH="$PATH:/opt/homebrew/bin"

然后關(guān)閉終端,再打開,再查看brew版本:

% brew --version
Homebrew 3.3.0
Homebrew/homebrew-core (git revision aace28c018f; last commit 2021-10-26)

可以了,然后再rvm安裝命令,安裝好后,再執(zhí)行sudo gem install cocoapods即可。最后查看一下:

% pod --version
1.11.2

3 至此,安裝完畢,收工。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 最近買了新的MacBookpro M1芯片的,著急忙慌得想要裝上xcode運(yùn)行下代碼看看運(yùn)行速度怎么樣.那么就要去...
    勤勞的小碼閱讀 12,431評(píng)論 22 23
  • 參考:剛發(fā)現(xiàn) 可參考鏈接[https://www.cnblogs.com/huihuizhang/p/143316...
    小專注閱讀 7,158評(píng)論 1 3
  • 前言:我們不去刪除系統(tǒng)自帶的ruby,而是自己重新安裝一套新的ruby,通過更改PATH環(huán)境變量的方式來更新系統(tǒng),...
    turbomx閱讀 682評(píng)論 0 0
  • 16宿命:用概率思維提高你的勝算 以前的我是風(fēng)險(xiǎn)厭惡者,不喜歡去冒險(xiǎn),但是人生放棄了冒險(xiǎn),也就放棄了無數(shù)的可能。 ...
    yichen大刀閱讀 7,974評(píng)論 0 4
  • 公元:2019年11月28日19時(shí)42分農(nóng)歷:二零一九年 十一月 初三日 戌時(shí)干支:己亥乙亥己巳甲戌當(dāng)月節(jié)氣:立冬...
    石放閱讀 7,494評(píng)論 0 2

友情鏈接更多精彩內(nèi)容