Building Flutter APKs and IPAs on Travis

APK and IPA are application packaging formats for Android and iOS respectively. When you are done building (and testing!) your Flutter app and ready to publish it to the Play Store and the App Store, you need to build an APK and an IPA. You can setup a continuous build of APKs and IPAs on Travis.

Building APKs

Officially Travis only supports the Android SDK on Linux. We need to set language to android, tell Travis to accept Android licenses and install a sufficient set of components. Assuming your Flutter app is at the root of the git repository, the .travis.yml file below has everything you need:

git clone https://github.com/flutter/flutter.git -b alpha --depth 1
./flutter/bin/flutter -v build apk

Building IPAs

IPAs can only be built on macOS and you need Xcode command-line tools installed. Luckily, you don’t need to know how Xcode command-line tools work. Flutter wraps all the xcode commands in a nice CLI. That said, if you are proficient with Xcode, a Flutter project is still a regular Xcode project, which you can build directly using the Xcode UI and command-line tools.

Building both using a build matrix

“But wait,” you say, “isn’t Flutter all about building both for Android and iOS?”

Making builds fast

The approach above works. However, there’s a little problem. All this Android and Xcode SDK installation and building takes time. If your project uses a pull request system, you might want pull requests to be checked for errors quickly and allow it to be merged. In my previous post I talked about Flutter’s super-fast UI testing framework. Running a Travis build that runs Flutter tests only takes a minute or two, which includes installing Flutter itself. APK/IPA building can add more than 10 minutes to the process. That can be annoying. What can we do about it?

Software Engineer @Google @Flutter, https://twitter.com/yegorjbanov

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store