Installing Flutter on MacOS
If you struggle with the installation of Flutter on MacOS, you are not alone.
You can start developing Flutter apps without any installation or configuration. You can quickly create prototypes and simple apps and share your code with fellow developers with an online tool called DartPad. It is an online open-source tool that runs on any browser.
However, if you are serious about programming with Flutter, there will come a time when you need to develop your apps locally and, therefore, will need to configure your system.
I went through some problems during the installation on MacOS, so here are the steps to make it work:
- Install Homebrew
- Install NodeJS by running this on your terminal
brew install nodejs
Android Studio
- Install a Java Runtime for the Android SDK. Latest versions of Android SDK want Java 11. I recommend the Azul Zulu JDK. You may use a different one, just make sure it’s Java 11.
brew install homebrew/cask-versions/zulu11 --cask
echo "export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home" >> ~/.zshrc
echo "export PATH=\"\$JAVA_HOME/bin:\$PATH\"" >> ~/.zshrc
- Install android-NDK
brew install android-ndk
echo "export ANDROID_NDK_HOME=\"/opt/homebrew/share/android-ndk\"" >> ~/.zshrc
source ~/.zshrc
- Install Android Studio
- run Android Studio from Launchpad
- click through the wizard on first launch
- create a blank project to complete installation - Click Tools -> SDK Manager:
- select SDK Tools tab
- install Android SDK Command-line Tools
echo "export PATH=\"\$HOME/Library/Android/sdk/cmdline-tools/latest/bin:\$PATH\"" >> ~/.zshrc
source ~/.zshrc
sdkmanager --update
sdkmanager --install "cmdline-tools;latest"
- Close Android Studio.
Xcode
- Install the latest stable version of Xcode (using web download or the Mac App Store).
- Configure the Xcode command-line tools
xcodebuild -runFirstLaunch
xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
- Install and set up CocoaPods(built with Ruby and it will be installable with the default Ruby available on macOS) by running the following commands:
sudo gem install activesupport -v 6
sudo gem install cocoapods
- If you are installing on an Apple Silicon Mac, run the command:
sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
Flutter
- Download the following installation archive to get the latest stable release of the Flutter SDK from: https://docs.flutter.dev/get-started/install/macos
- Recommended to extract and mv flutter dir to ~/flutter
echo "export FLUTTERPATH=\$HOME/flutter" >> ~/.zshrc
echo "export PATH=\"\$PATH:\$FLUTTERPATH/bin\"" >> ~/.zshrc
source ~/.zshrc
- I recommend the stable channel for new users and for production app releases
flutter channel stable
- To update the Flutter SDK use:
flutter upgrade
- Before you can use Flutter, you must agree to the licenses of the Android SDK platform. Run the following command to begin signing licenses:
flutter doctor --android-licenses
- This step is more to avoid any troubles with installation(even I downloaded the archive with necessary development binaries, there still can be missing binaries, so I would recommend to do this step):
flutter precache
- If you’re installing on an Apple Silicon Mac, you must have the Rosetta translation environment available for some ancillary tools. You can install this manually by running:
sudo softwareupdate --install-rosetta --agree-to-license
- Run the following command to see if there are any dependencies you need to install to complete the setup and check if all stages are completed:
flutter doctor
If you’ve got “No issues found!” , my congratulations! You made it 💪
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.X, on macOS XX.X XXXXX X, locale
en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version XX.X.X)
[✓] Xcode - develop for iOS and macOS (Xcode XX.X.X)
[✓] Chrome - develop for the web
[✓] Android Studio (version XXXX.X)
[✓] IntelliJ IDEA Ultimate Edition (version XXXX.X.X)
[✓] VS Code (version X.XX.X)
[✓] Connected device (X available)
[✓] Network resources
IntelliJ Plugins:
- Dart
- Flutter
- Flutter Intl
- Flutter Snippets
- Makefile
Official Flutter documentation on MacOS installation: https://docs.flutter.dev/get-started/install/macos
Now you are ready to create your first Flutter app! :)