Setting up the Flutter on M1 Mac

At the time of writing this article, the latest stable version of the Flutter is 2.5. Flutter version 2.5 improved supporting Apple Silicon, in version 2.5, the iOS simulator now natively run on Apple Silicon.

This article explains how to set up the Flutter on M1 Mac.

Download and Install SDK

Download the stable codes of the Flutter from the official web site.

Flutter | Flutter – Beautiful native apps in record time

Expand the downloaded archive, move expanded flutter folder into the directory you want to install. For example, I copied it into the ~/Documents/src/ directory.

Edit the environment variable

Edit ~/.zshrc file to add the path to the flutter directory to the PATH environment variable.

export PATH=~/Documents/src/flutter/bin:$PATH

Diagnostic

Run diagnostic with the flutter doctor. In this machine, all of needed tools are uninstalled.

flutter doctor exported below.

% flutter doctor
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
Building flutter tool...
Doctor summary (to see all details, run flutter doctor -v):
Failed to find the latest git commit date: VersionCheckError: Command exited with code 1: git -c log.showSignature=false log -n 1
--pretty=format:%ad --date=iso
Standard out: 
Standard error: xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or
use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.

Returning 1970-01-01 09:00:00.000 instead.
[✓] Flutter (Channel unknown, 0.0.0-unknown, on macOS 11.5.2 20G95 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 installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods.
      To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[!] Connected device
    ! No devices available

! Doctor found issues in 5 categories.

This machine, following tools is not installed and there are necessary tools.

  • Xcode (for macOS Desktop Apps and iOS apps)
  • Android Studio (for Android Apps)
  • Chrome (for the web apps)

Install Xcode

Xcode can be downloaded from the Mac App Store. After installed, launch it. At the first time, the required system modules will be installed.

For the Flutter, additional operations are needed.

(1) Set the path to the Xcode will be used by command line tools.

% sudo xcode-select -s /Applications/Xcode.app

(2) Agree to the license agreement of the Xcode.

% sudo xcodebuild -runFirstLaunch

(3) Agree to the license agreement of the SDKs.

% sudo xcodebuild -license

(4) Launch Xcode and configure your Apple Developer Account and certificates.

Install CocoaPods

Flutter uses CocoaPods, so install the CocoaPods.

% sudo gem install cocoapods

Install Google Chrome

Flutter can build the web app and uses Chrome to run. Download from the official web site.

Google Chrome – Download the Fast, Secure Browser from Google

Install JDK

Currently writing.

Install Android Studio

Related

This article is a guide of setting up Android Studio on M1 Mac. Install Android Studio Download from the official site[…]

Run diagnostic

Finally, run diagnostic.

% flutter doctor

If you completed resolved all issues, it will export below.

No issues found!
Sponsored Links
Get the Latest News !

Developer ToolsLatest 8 Posts