//
Home Blog Tech Make Better Mobile Apps by Utilizing Build Automation Tools

Make Better Mobile Apps by Utilizing Build Automation Tools

It’s common knowledge that people tend to make small mistakes in repetitive tasks. One on such tasks is build preparations. On the other hand, computers are masters of the repetitive well-organized work.

So, let me tell you how you can benefit from build automation in your project and how to include it for you mobile app development.

Why it’s worth to consider build automation?

Because it’s time, productivity, and quality gain.

Preparing another app version build – even if it’s simple, repetitive task – is relatively time consuming. Let’s say it takes 35 minutes to prepare it. When using build automation tool, in most cases it’ll take like 5 minutes or less to request build. It’s half an hour which a programmer could actually spend coding.

Here is our time and productivity gain, but what about quality, you ask? I believe everyone agrees that the sooner an app is provided to QA team the more time could be spent on tests in parallel to programmers developing another thing. By giving QA team more time, we could ensure better quality.

You could argue that the same could be done without using automated tools. That’s true, just keep in mind that time difference I mentioned. If you would like to prepare the app a few times a day, this time ads up. Why? The best practices suggest to provide incremental builds whenever something changes, e.g., when new feature was added or some bug was fixed, etc. So, using build automation allows us to follow the best practices without spending too much time.

Plus, using build automation tools is a good step for using automated tests, but that topic for another time.

Well, by now you should know the upsides, but unfortunately there is a downside to this approach… and it’s time. I’ve just pitched to you how much time could you get by using build automation tools, but they need to be configured, first. I’m mentioning this as a downside but it’s not as big of a deal the longer the project is and the longer it benefits from build automation.

I’m sold, what are my options?

There are plenty of available online platforms for you to consider. I’ve listed a few of them below with a short description and a link to the official site.

  • AppCenter – It’s Microsoft solution to continuously build, test, release, and monitor apps for every platform. By every platform they mean iOS and Android written natively or using one of the cross-platform technologies. Plus, Windows, macOS, tvOS or Unity Apps.
  • Bitrise – this one is only for mobile Apps developed both using native & cross-platform technologies. The biggest advantage of this solution is a large number of ready-made plugins that take care of most things. Moreover, if a given plug-in is not available, it is relatively easy to create and use your own plug-in.
  • CodeMagic – another one that’s purely focused on mobile Apps. It owes its popularity to the fact that it was first platform that allowed to automate build process for Flutter mobile Apps.

I’ve my pick, how to use it in practice?

Well, first of all, you need your code to be uploaded to some remote git repository. I’ll work on an assumption you already have that; you can build your app on your local machine and know everything about signing the app.

All of the tools share some similarities. Every one of them requires you to connect the account from building site with the account that can access your git repository. This step also requires you to add a required permission for the build to work flawlessly. Next step is to pick a repository of the app. After doing so you need to configure how your build should be prepared. Some tools are configured per branch, others have workflows that are connected with some triggers. That’s the place when you tell tool how to build your App e.g. how should it be signed, to what backend url should it be connected or which version number should be used. When those things are setup, you can run build and then get you *.apk or *.ipa files.

Now that you get the basic idea how it works let me show you quick overview of how it’s done on previously mentioned sites for Android & Flutter Apps.

1. AppCenter

You need to log in and create a new app. Next, you should see a dashboard similar to the one on the image below. When adding a new app, you need to provide a few things. For a native Android App, pick Android OS. Then choose a Java/Kotlin platform. If you’ve built a Flutter app, then Android should use the same settings like I’ve just described, but for iOS you need to pick an iOS as OS and then Objective-C/Swift as a platform.

Hit “Build” on the left side menu to go further.

Now, you need to connect your AppCenter account with the account which could access your online repository. After doing so, pick repository that you wish to automatically build. Right now you should see all branches when in “Build” tab.

Pick a branch you wish to build automatically, click it and then click “Configure build”. Doing so should leave you with a screen like the one below, in which you should provide build configuration, e.g. app module, build variant, when a build should be triggered, what keys or certificates shall be used to sign the app, and so on. Provide those and tap on “Save & Build”.

This will start the first build for you, wait patiently for it to end successfully.

One important note here. To successfully build a Flutter App, you need to add two scripts to a repository called appcenter-post-clone.sh.

For Android in /android/app/ folder with content of:

#!/usr/bin/env bash
cd ..
set –e
set –x
cd ..
git clone -b stable https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel stable
flutter doctor
flutter build apk –release
mkdir -p android/app/build/outputs/apk/; mv build/app/outputs/apk/release/app-release.apk $_

For iOS in iOS/ folder with content of:

#!/usr/bin/env bash
set –e
set –x
cd ..
flutter channel stable
flutter doctor
flutter build ios --release --no-codesign

Those two will install Flutter on a machine build of your app before the build starts. Microsoft AppCenter is looking for two other scripts that you could utilize if you wish. One if executed before the build and another in post build. If you’re interested in them, just check Microsoft AppCenter docs.

2. Bitrise

Bitrise has the same workflow for both Android and Flutter apps. Similar to AppCenter, you need to create an account and then add a new app. Just choose a connected online git account, then a project and a branch you wish to automatically build.

After doing so, Bitrise will verify your project and try to find the best predefined project setup for your needs, so sit tight.

When verification is done you’ll setup things like app module, build variant, when a build should be triggered, what keys or certificates shall be used to sign the app, and so on.

Right now your first build should kick in. So we are done.

Note: It’s possible that automatically created workflow will be faulty so make sure that for Android it contains Android Build step and for Flutter – a Flutter Install and Flutter Build steps.

3. CodeMagic

With CodeMagic, everything starts similar: you need to create an account and connect your repositories.

Then, you should pick a workflow. For Flutter App choose Flutter App, for Android go for Android App:

Now it’s time to provide your build configuration. For Flutter App you simply provide app module, build variant, when a build should be triggered, what keys or certificates shall be used to sign the app and, so on via CodeMagic site. Things are getting more interesting if you want to build a native Android app. This one requires you to add the file called codemagic.yaml in the root directory. Most basic codemagic.yaml file could look like this:

workflows:
    android-app:
        name: WalkiWalki
        scripts:
            - ./gradlew assembleDebug
        artifacts:
            - app/build/outputs/**/*.apk

If you would like to know more about this *.yaml file check the official docs.

When the config is in place, select branch you desire to build and click “Start”.

Summary

I hope that by now you see why introducing automated build tools in your project is a good thing. You can take advantage of this approach by saving time, increasing productivity and the quality of your project – especially in a long run. What’s more, you now have three available options to try out and build your Android or Flutter App.

Spread the word ...

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn