Mendix Native builds with Bitrise
Introduction
Building native mobile apps can be a hassle. Mendix has supported app builds using Microsoft AppCenter to take away part of that burden. However, AppCenter will be discontinued.
Mendix moves forward by enabling us developers to use any build tool, starting with Bitrise. Bitrise is a really beautiful and easy to use CI/CD tool. It features a user friendly UI while still allowing access to all the details whenever you would need to. Setup really is hassle free. Usually it works with the defaults and values detected from the native app build project as generated from the Mendix project.
Starting point
This blog post continues using the build as created using the Mendix docs on using Bitrise. That build looks like the image below. Note that I renamed the two NPM steps to make it more clear what they do. The display name can be adjusted in the workflow step properties.
Assuming you want your builds to be triggered with each push to the repository: be sure to configure the push triggers before continuing.
Separate workflow for each platform
The current configuration builds both iOS and Android using the Xcode stack. This works just fine but bear in mind that you’re on a monthly credit budget at Bitrise. Each build uses Bitrise build credits. If you have more than two private apps, you need at least a Teams plan, which has a monthly limit depending on your plan details. The number of credits required for your build depends greatly on the number of dependencies you have in your app.
The stack used for your build also affects credit usage. More powerful stacks and macOS stacks take more credits per minute.
Your Android app will build just fine on the Xcode stack, but at two credits per minute. The Ubuntu stack would do the job too, at one credit per minute.
So let’s split up the workflow for the two platforms!
Copy the workflow
Click the workflow dropdown to open it and choose to create a new workflow. Choose a new name, for example deploy-Android and choose to base it on the deploy workflow:
Take out the iOS steps by hovering over each step and clicking the trash icon:
- Run CocoaPods install
- Manage iOS Code Signing
- Xcode Archive & Export for iOS
After removing these steps the workflow looks like this:
Use Ubuntu stack
However, the workflow is still using the Xcode stack. Let’s change that. Click Stacks & Machines in the workflow editor sidebar
Scroll down to access the Workflow Specific Stacks. For the deploy-Android workflow, choose the most recent Ubuntu stack. Save the changes
Note that the smallest machine type uses one credit per minute, where the Xcode stacks start at two credits per minute
Now the workflow uses the Ubuntu stack:
Adjust iOS workflow
In the workflow dropdown, select the deploy workflow. Take out the Android steps:
- Install missing Android SDK components
- Android Build
- Android Sign
On the workflow properties tab, rename the workflow using the edit button on the workflow name.
Choose a new name, for example deploy-iOS and press enter to confirm it. Also save the changes using the top-right button. The workflow now looks like this:
Now you have separate workflows for iOS and Android, which saves credits on the Android builds.
As a bonus, if you configured triggers, the workflows are started in parallel after each push to the repository !