Build a Mendix Native App with Bitrise
Introduction
This guide helps you set up Bitrise to automate building a Mendix native app in the cloud. Bitrise is a popular continuous integration service optimized for mobile apps.
Prerequisites
Before starting this guide, make sure you have completed the following prerequisites:
- Signed up for a GitHub account and created a personal access token
- Signed up for a Bitrise account
- Read the Getting Starting guide from Bitrise and understand the key concepts of Bitrise
- Have access to a Mendix application project with a native mobile profile as a developer
- The Mendix application is deployed
- Have created the native template project for your app by following Using Mendix Native Mobile Builder to Set Up Your Local App. Make sure to set the GitHub token to also create a GitHub repository.
- Fulfilled the prerequisites below for all operating systems you want to target:
Prerequisites for iOS
- Signed up as an Apple developer
- Joined the Apple Developer Program or the Apple Developer Enterprise Program
- You have access to an Apple distribution certificate
- You have created an API Key for App Store Connect
Prerequisites for Android
- Signed up as an Android developer
- Created a Keystore with Android Studio or with Java
Set Up Your Build Project
To set up your build project, do the following:
-
Create a workspace (if needed) in Bitrise.
-
Create a new project in the workspace.
-
Select the GitHub project generated by Build Native App as the repository. It is recommended to use the GitHub App Integration:
-
Select the
master
branch and let Bitrise auto-detect the configuration. -
Confirm that the correct configuration has been detected:
- Project type:
React Native
- Project directory:
.
- Root directory of Android project:
android
- Module:
app
- Variant:
appstoreRelease
- Project or Workspace path:
ios/NativeTempalte.xcworkspace
- Scheme name:
nativeTemplate
- Distribution method: Choose the distribution method you want to use
- Build stack: Choose the latest Xcode version compatible with your Mendix version
- Project type:
-
Finish creating the project.
-
Abort the build if one starts automatically (you first need to setup code signing and adjust the workflow).
Setup Code Signing for iOS
Applications distributed to iOS devices must be signed with a certificate and a provisioning profile. To do so, you need to register as a developer with Apple and join one of their development programs (see Prerequisites).
Bitrise supports automatic provisioning via a constant connection with the App Store. To set it up, follow the guide from Bitrise.
If you prefer to manually set up provisioning, follow this guide from Bitrise instead.
Setup Code Signing for Android
Applications distributed to Android devices must be signed with a keystore. To distribute Android apps via the PlayStore, you must also register as an Android developer (see Prerequisites).
Bitrise lets you store your Android keystore in the build project. Follow this guide from Bitrise to upload and store the keystore.
Adjust Workflow
The default workflow (deploy) needs to be extended to work for Mendix native mobile apps. Open the build project and click on Workflow to access the workflow editor. With it, you can customize the commands you run in order to build your application.
Any additional workflows that may have been created can be removed. Select the workflow from the dropdown and click Properties > Delete workflow.
Add Missing npm Command
Add a missing npm command by doing the following:
- Add a new step after the step “Run npm command”.
- Choose Run npm command from the list of steps.
- Set the npm command with arguments to run to
run configure
. - Save changes.
Remove Unneeded Operating System Targets
By default, Bitrise targets both Android and iOS. If you do not need to build for both operating systems (OS), remove all actions related to that OS and skip all steps below related to it as well.
For example, if you only target iOS, you can remove the actions Install missing Android SDK components and Android Build. This will significantly speed up your builds and save credits.
Add Android Code Signing (Android only)
To add Android code signing, do the following:
- Add a new step after the step Android Build.
- Choose Android Sign from the list of steps.
- Save changes.
Bitrise will use the uploaded keystore to sign the .apk.
Add Cocoapods Install (iOS only)
To add Cocoapods install on iOS, do the following:
- Add a new step before the step Xcode Archive.
- Choose Run CocoaPods install from the list of steps.
- Set Workdir to
$BITRISE_SOURCE_DIR/ios
- Save changes.
This step will install the dependencies required for iOS.
Add iOS Code Signing (iOS Only)
- Add a new step before the step Xcode Archive (after Run CocoaPods install).
- Choose Manage iOS Code Singing from the list of steps.
- Set the distribution method to the method selected in section 3.
- Save changes.
Bitrise will use the provided iOS Signing information to sign the iOS app.
After these changes, your workflow should look like this (if you target both operating systems):
Build Your App
Builds can be started manually or automatically. To start a build manually, open the build project and click Start build and confirm the dialog. A typical build will take approximately 20 minutes, but can take longer for complex applications with many dependencies.
When building, you can follow the build output and watch for progress and potential problems being reported there.
To set up automatic builds after running Build Native App, follow these steps:
- Open the Workflow Editor of your build project.
- Open the Triggers page.
- Click Add push trigger.
- Select Push branch for Condition 1 and change the Push branch to
master
. - Select the deploy workflow and confirm.
Now, every time some runs Build Native App to update the application bundle, a new build will be triggered in Bitrise.
Additional Considerations
Our MVP Marcel Groeneweg has written a blog post about optimizing Mendix native mobile builds with Bitrise. Check it out on Medium (Mendix cannot take responsibility for third-party recommendations).