Flutter開発環境をmacOS Big Surに構築する
現在のFlutterではdart langがSDKとともにインストールされる。
だkらまずSDKのインストールを実行する。
Flutter SDK のインストール
SDKはhttps://flutter.dev/docs/get-started/install/macosでダウンロードする。
cd ~/development(解凍先)
unzip ~/Downloads/flutter_macos_1.22.6-stable.zip
PATHの追加
export PATH="$PATH:`pwd`/flutter/bin"
これだとターミナルを再起動するとPATH変数は元に戻る。だから.zshrcに追加する必要がある。
まず
echo $PATH
とやって最後に追加されている変数をコピーして~/.zshrcに追加。Vimでもなんでもいい。
export PATH=$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin
[PATH_TO_FLUTTER_GIT_DIRECTORY]の部分は自分で入れた場所。
source ~/.zshrc
とやってエラーが出なければ大丈夫。確認のため新たなターミナルを開いて
echo $PATH
で入力したPATHが表示されればOK。
$ which flutter dart
/path-to-flutter-sdk/bin/flutter
/usr/local/bin/dart
ちゃんと入っているようだ。
各種設定を実施
これは現在の環境によって異なるが、それを調査し不足しているものを指摘してくれるスクリプトがflutter doctorである。
% flutter doctor
Downloading Dart SDK from Flutter engine 2f0af3715217a0c2ada72c717d4ed9178d68f6ed...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 172M 100 172M 0 0 9.8M 0 0:00:17 0:00:17 --:--:-- 10.1M
Building flutter tool...
╔════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - https://flutter.dev ║
║ ║
║ The Flutter tool uses Google Analytics to anonymously report feature usage ║
║ statistics and basic crash reports. This data is used to help improve ║
║ Flutter tools over time. ║
║ ║
║ Flutter tool analytics are not sent on the very first run. To disable ║
║ reporting, type 'flutter config --no-analytics'. To display the current ║
║ setting, type 'flutter config'. If you opt out of analytics, an opt-out ║
║ event will be sent, and then no further information will be sent by the ║
║ Flutter tool. ║
║ ║
║ By downloading the Flutter SDK, you agree to the Google Terms of Service. ║
║ Note: The Google Privacy Policy describes how data is handled in this ║
║ service. ║
║ ║
║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and ║
║ crash reports to Google. ║
║ ║
║ Read about data we send with crash reports: ║
║ https://flutter.dev/docs/reference/crash-reporting ║
║ ║
║ See Google's privacy policy: ║
║ https://policies.google.com/privacy ║
╚════════════════════════════════════════════════════════════════════════════╝
Downloading Material fonts... 0.4s
Downloading Gradle Wrapper... 0.0s
Downloading package sky_engine... 0.1s
Downloading flutter_patched_sdk tools... 1.4s
Downloading flutter_patched_sdk_product tools... 1.4s
Downloading darwin-x64 tools... 3.6s
Downloading libimobiledevice... 0.0s
Downloading usbmuxd... 0.0s
Downloading libplist... 0.0s
Downloading openssl... 0.2s
Downloading ios-deploy... 0.0s
Downloading darwin-x64/font-subset tools... 0.3s
Downloading android-arm-profile/darwin-x64 tools... 0.4s
Downloading android-arm-release/darwin-x64 tools... 0.3s
Downloading android-arm64-profile/darwin-x64 tools... 0.5s
Downloading android-arm64-release/darwin-x64 tools... 0.3s
Downloading android-x64-profile/darwin-x64 tools... 0.5s
Downloading android-x64-release/darwin-x64 tools... 0.3s
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-x64, locale
ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[!] Xcode - develop for iOS and macOS (Xcode 12.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:
sudo gem install cocoapods
[!] Android Studio (version 4.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
[!] VS Code (version 1.53.1)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 5 categories.
あとは指摘に従って各種設定を行えばいい。Flutterの開発にAndroid Studio, IntelliJ IDEA, VS Codeのどれを使うかによって、入れるべきプラグインは異なるだろう。
Android Studioの場合、Marketplaceのプラグインがダウンロードできないということがあるようなので、その場合、IntelliJ IDEAを使う。
最後にもう一度flutter doctorを実行して問題なければ開発に進める。