在 Mac 中建置 Flutter App 開發環境時,處理 licenses not accepted 與CocoaPods not installed.

黃色警告 [!] 為 warning

[!] Android toolchain — develop for Android devices (Android SDK version 34.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor — android-licenses

此錯誤說明有些 Android 尚未取得授權,依照說明執行取得授權

flutter doctor --android-licenses

接下來的詢問都按 Y ,同意此 licenses ,此警告就消失了

[!] Xcode — develop for iOS and macOS (Xcode 15.4)
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side’s plugin
code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see
https://guides.cocoapods.org/using/getting-started.html#installation for
instructions.

套件 Cocoapods 跟 iOS 原生的程式有關係,開發 Flutter App 時,有用此套件但沒安裝執行時會出錯誤。
安裝 Cocoapods 。

sudo gem install cocoapods

遇到新的問題:需要更新 drb的版本

gem install drb -v 2.0.6

再來新的問題:遇到沒有權限異動,現在此資料夾的權限在 root 上,需要將將權限給自己

sudo chown -R YourUserName /Library/Ruby/Gems/2.6.0

再次更新 drb的版本,更新完

再次執行 sudo gem install cocoapods

新的問題:需要安裝 activesupport

再次執行 sudo gem install cocoapods,然後執行 flutter doctor 來幫我們診斷目前開發環境是否正常。

終於看到全部的綠色勾勾和 No issues found。

新執行 flutter doctor 發現新的錯誤。

依照說明輸入指令

sudo softwareupdate --install-rosetta --agree-to-license

此警告就消失了

--

--