Closed6
Flutter環境構築メモ (M2 macOS)
M2 Macbookを買ったので環境構築メモ
- MacBook Air (M2, 2022)
- macOS Monterey v12.5
Homebrew
- install
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- warning
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!
- Pathを通すためにNext stepsを実行
==> Next steps:
- Run these three commands in your terminal to add Homebrew to your PATH:
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/{ユーザ名}/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/{ユーザ名}/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- 確認
$ brew --version
Homebrew 3.6.14
Homebrew/homebrew-core (git revision ba649aabd71; last commit 2022-12-11)
Git
Apple Git
なるものが入っていたが、homebrewからgit入れる。
$ brew install git
$ touch ~/.zshrc #ファイルなければ作成
.zshrc
export PATH=$HOME/mycommands:$PATH
確認
$ git -v
git version 2.38.2
Flutter (macOS install)
macOSでは以下の実行が必要。
$ sudo softwareupdate --install-rosetta --agree-to-license
こちらからinstallしてpathを通す
.zshrc
export PATH="$PATH:`pwd`/flutter/bin"
path確認
$ flutter --version
Flutter 3.3.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b8f7f1f986 (3 weeks ago) • 2022-11-23 06:43:51 +0900
Engine • revision 8f2221fbef
Tools • Dart 2.18.5 • DevTools 2.15.0
この時点で色々確認。
(XcodeをApp storeからinstall済み。Chromeをinstall済み)
$ flutter doctor
Running "flutter pub get" in flutter_tools... 6.1s
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.5 21G72 darwin-arm, locale
ja-JP)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ 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.
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 4 categories.
まずXcodeの部分
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ 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.
以下を順に実行
$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
$ sudo xcodebuild -runFirstLaunch
CocoaPodsをhomebrewでinstall
$ brew install cocoapods
確認
$ flutter doctor
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
次はAndroidStudioの部分
[!] Android Studio (not installed)
こちらから「Mac with Apple chip」でダウンロードする。
確認
$ flutter doctor
[✓] Android Studio (version 2021.3)
Android Studioを起動する。
初回起動だと「Android Studio Setup Wizard」が出るので進めていく。
これを終えれば以下のErrorがちょっと変わる。
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
↓
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for
more details.
Android StudioのPreference、Android SDKのSDK Toolsタブで「Android SDK Command-line Tools(latest)」にチェックを入れてApply
次に以下を実行
$ flutter doctor --android-licenses
確認
$ flutter doctor
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
最終確認
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.5 21G72 darwin-arm, locale
ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
• No issues found!
このスクラップは2022/12/11にクローズされました