chakokuのブログ(rev4)

日々のごった煮ブログです

Flutter インストールメモ

MacbookにFlutterを入れる。。
Apple siliconはなんとかと書かれていて、rosettaを入れろとなっている(と理解)
Developing with Flutter on Apple Silicon · flutter/flutter Wiki · GitHub

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

あとは、Flutterのサイトの説明に従ってインストール
macOS install | Flutter
FlutterのZIPを落として展開して、パスを通してdoctorを実行してみる。AndroidXCodeCLIセットアップがNGと怒られる。確かにまだやっていない。

 % flutter doctor
Running "flutter pub get" in flutter_tools...                       8.9s
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.1, on macOS 12.2.1 21D62 darwin-arm, locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ 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.
[✗] 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 (version 2021.1)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

! Doctor found issues in 2 categories.

XCodeのcommand line ツールを以下でセットアップ

 sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
 sudo xcodebuild -runFirstLaunch

runFirstLaunchでは2つあるうちの1つを使うよと言ってるような・・・これでいいのか?

%  sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Password: XXXXXXX

%  sudo xcodebuild -runFirstLaunch
objc[12234]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x20f7a7678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1087602c8). One of the two will be used. Which one is undefined.
objc[12234]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x20f7a76c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108760318). One of the two will be used. Which one is undefined.

以下のコマンドでcocoa podsを入れる

sudo gem install cocoapods

cocoa podsを入れた後再度doctorで確認、先ほどの2つあるよの件は出てこず、AndroidCLIのみ未対応の状況

% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.1, on macOS 12.2.1 21D62 darwin-arm, locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ 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.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

Androidのセットアップがまだなのだが、、待ちきれず、以下のサンプルを実行

$  flutter create test01
$  cd test01
$  flutter run

特にエラーも出ずに、EmulatorとしてiPad miniが起動された。

なぜiPad mini?? XCodeで細かく設定していないからデフォルト?が呼び出された?

Android Studioを入れて、SDKも入れたつもりなのだが、flutter doctor で確認すると依然としてエラー表示される

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ 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.

上記解消手順に従ってコマンドを実行してみるが、sdkmanagerが見つけられない。そもそもcomand line toolsをインストールしていないのでは?と思われ、再度、SDKManagerからCLIツールをインストール doctor でチェックした結果、ライセンスのチェックだけ残っている状態になった。

% flutter doctor --android-licenses

% flutter doctor                   
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.1, on macOS 12.2.1 21D62 darwin-arm, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Connected device (3 available)
    ! Error: ipodune is busy: Fetching debug symbols for ipodune. Xcode will continue when ipodune is finished. (code -10)
[✓] HTTP Host Availability

• No issues found!

doctor によるチェックでは以上でインストール完了と思われる。flutterで使えるEmualtorと実機を確認

% flutter emulators

2 available emulators:
apple_ios_simulator       • iOS Simulator             • Apple  • ios
Pixel_3a_API_32_arm64-v8a • Pixel_3a_API_32_arm64-v8a • Google • android


% flutter devices

3 connected devices:
sdk gphone64 arm64 (mobile) • emulator-5554                            • android-arm64  • Android 12 (API 32) (emulator)
ipodune (mobile)            • 467171fxxxxxxxxxxxxxx34e • ios            • iOS 15.3.1 19D52
Chrome (web)                • chrome                                   • web-javascript • Google Chrome 98.0.4758.102

上記の様に、一通りの機器が利用可能なようだ。インストールはOKと思われ、Flutter Cookbook ; 100 によるサンプルコードでの勉強に移る。
Githubにソース一式あるのでそちらから落とせよとある。
GitHub - PacktPublishing/Flutter-Cookbook: Flutter Cookbook, published by Packt