The official way to install the flutter and its dependencies is a mishmash of brew install
, binary downloads alongside relying on system installed versions of ruby.
I became particularly frustrated when trying to setup flutter on macOS Mojave and macOS Catalina. I came across too many issues, and it took a lot of stackoverflow and google searches to overcome.
By using a package manager to install dependencies and runtimes, we can share the exact same setup in different environments and automate the install and escape the above issues.
This is particularly valuable if you use different machines, or have team members in different locations. Moreover, we know where everything belongs and how to upgrade or uninstall if necessary.
Until a complete homebrew approach is released, I think this is a decent step by step approach.
You need to make sure you have homebrew installed and also asdf to manage runtime dependencies.
If you don't have asdf installed already, you can follow my tutorial on how to install asdf
You should also install xcode via the mac app store. This could take a while depending on your download speed.
This will install the dependencies for flutter and asdf which we will use to install the runtimes.
We're installing:
- asdf for our
dart
,flutter
andruby
runtimes - android sdk for command line util
sdkmanager
- android studio to build flutter apps for android
- intel haxm to help speed up flutter rendering
- adoptopenjdk8 prebuilt java binary to make sure the above android stuff works
brew install asdf
brew install android-sdk
brew install android-studio
brew install haxm
brew cask install adoptopenjdk8
There are three steps for asdf, but this won't take long except depending on your download speed.
- Install the asdf plugins for
dart
,flutter
andruby
asdf plugin install dart https://github.com/patoconnor43/asdf-dart.git
asdf plugin install flutter
asdf plugin install ruby https://github.com/asdf-vm/asdf-ruby.git
- Install the actual runtimes
- latest version of dart
- latest stable version of flutter
- We will use ruby 2.3.7 because it allows us to install cocoapods on macOS catalina.
You can use the latest version of Ruby if you like, but I've come across issues.
asdf install dart 2.7.0
asdf install flutter 1.12.13+hotfix.7-stable
asdf install ruby 2.3.7
- Set the runtimes to global or local. You can set these to local if you have multiple projects that rely upon different versions.
asdf global dart 2.7.0
asdf global flutter 1.12.13+hotfix.7-stable
asdf global ruby 2.3.7
We don't need to use sudo
we can install direct into the asdf ruby version.
gem install cocoapods
The latest version of cocopads (1.8.4) doesn't respect the pod setup
command on macOS catalina, so we have to use an older version until this bug is resolved.
gem install cocoapods -v 1.7.5
Install the cocoapods dependencies
pod setup
You will need to install the flutter and dart plugins for android studio, otherwise flutter doctor
will complain later on.
Simply open up the app, go to configure > plugins
and then install from the dialog as shown below.
We need to accept the licences for xcode in order to build ios apps
sudo xcodebuild -license
We need to accept the android licences in order to build our flutter app for android
flutter doctor --android-licenses
Run sdkmanager
to make sure all dependencies are installed (depends on adoptopenjdk8
that we installed via brew)
sdkmanager
You might need to add these into your .zshrc
or .bash_profile
files if you get complaints about haxm or java.
export INTEL_HAXM_HOME=/usr/local/Caskroom/intel-haxm
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Finally lets check our flutter install
flutter doctor -v
This is what you should see if all the above was done right.
After completing all the above steps we now know that dart
, flutter
, ruby
are all managed via asdf.
The remaining dependencies are all installed via homebrew. Updates and upgrades should be straightforward, and we can document builds and releases to a particular setup.
Happy coding!
The Github URL for asdf-dart seems to be case sensitive, https://github.com/PatOConnor43/asdf-dart.git was what worked for me. Thank you for putting this together!