|
| 1 | +--- |
| 2 | +title: "Build a Mendix Native App with Bitrise" |
| 3 | +url: /refguide/mobile/distributing-mobile-apps/building-native-apps/bitrise/ |
| 4 | +weight: 60 |
| 5 | +description: Describes how to integrate with Bitrise to build a Mendix native app in the cloud. |
| 6 | +--- |
| 7 | + |
| 8 | +## Introduction |
| 9 | + |
| 10 | +This guide helps you set up [Bitrise](https://bitrise.io) to automate building a Mendix native app in the cloud. Bitrise is a popular continuous integration service optimized for mobile apps. |
| 11 | + |
| 12 | +## Prerequisites {#prerequisites} |
| 13 | + |
| 14 | +Before starting this guide, make sure you have completed the following prerequisites: |
| 15 | + |
| 16 | +* Signed up for a [GitHub account](https://github.com/signup) and created a personal access token |
| 17 | +* Signed up for a [Bitrise account](https://app.bitrise.io/users/sign_up) |
| 18 | +* Read the [Getting Starting guide from Bitrise](https://devcenter.bitrise.io/en/getting-started.html) and understand the key concepts of Bitrise |
| 19 | +* Have access to a Mendix application project with a native mobile profile as a developer |
| 20 | + * The Mendix application is deployed |
| 21 | +* Have created the native template project for your app by following [Using Mendix Native Mobile Builder to Set Up Your Local App](/refguide/mobile/distributing-mobile-apps/building-native-apps/native-build-locally/#using-mendix-native-mobile-builder-to-set-up-your-local-app). Make sure to set the GitHub token to also create a GitHub repository. |
| 22 | +* Fulfilled the prerequisites below for all operating systems you want to target: |
| 23 | + |
| 24 | +### Prerequisites for iOS {#prerecs-ios} |
| 25 | + |
| 26 | +* Signed up as an [Apple developer](https://developer.apple.com/programs/enroll/) |
| 27 | +* Joined the [Apple Developer Program](https://developer.apple.com/programs/) or the [Apple Developer Enterprise Program](https://developer.apple.com/programs/enterprise/) |
| 28 | +* You have access to an [Apple distribution certificate](https://developer.apple.com/help/account/create-certificates/create-developer-id-certificates) |
| 29 | +* You have [created an API Key for App Store Connect](https://developer.apple.com/documentation/appstoreconnectapi/creating-api-keys-for-app-store-connect-api) |
| 30 | + |
| 31 | +### Prerequisites for Android {#prerecs-android} |
| 32 | + |
| 33 | +* Signed up as an [Android developer](https://play.google.com/console/signup) |
| 34 | +* Created a Keystore [with Android Studio](https://developer.android.com/studio/publish/app-signing#generate-key) or [with Java](https://docs.oracle.com/cd/E19509-01/820-3503/ggfen/index.html) |
| 35 | + |
| 36 | +## Set Up Your Build Project |
| 37 | + |
| 38 | +To set up your build project, do the following: |
| 39 | + |
| 40 | +1. Create a workspace (if needed) in Bitrise. |
| 41 | +1. Create a new project in the workspace. |
| 42 | +1. Select the GitHub project generated by **Build Native App** as the repository. It is recommended to use the **GitHub App Integration**: |
| 43 | + |
| 44 | + {{< figure src="/attachments/refguide/mobile/distributing-mobile-apps/building-native-apps/bitrise/select-repository.png" alt="Select repository" width="350" class="no-border" >}} |
| 45 | + |
| 46 | +1. Select the `master` branch and let Bitrise auto-detect the configuration. |
| 47 | +1. Confirm that the correct configuration has been detected: |
| 48 | + * Project type: `React Native` |
| 49 | + * Project directory: `.` |
| 50 | + * Root directory of Android project: `android` |
| 51 | + * Module: `app` |
| 52 | + * Variant: `appstoreRelease` |
| 53 | + * Project or Workspace path: `ios/NativeTempalte.xcworkspace` |
| 54 | + * Scheme name: `nativeTemplate` |
| 55 | + * Distribution method: [Choose the distribution method you want to use](https://developer.apple.com/videos/play/wwdc2019/304/) |
| 56 | + * Build stack: Choose the altest Xcode version compatible with your Mendix version |
| 57 | +1. Finish creating the project. |
| 58 | +1. Abort the build if one starts automatically (you first need to setup code signing and adjust the workflow). |
| 59 | + |
| 60 | +## Setup Code Signing for iOS |
| 61 | + |
| 62 | +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](#prerequisites)). |
| 63 | + |
| 64 | +Bitrise supports automatic provisioning via a constant connection with the App Store. To set it up, follow [the guide from Bitrise](https://devcenter.bitrise.io/en/code-signing/ios-code-signing/managing-ios-code-signing-files---automatic-provisioning.html). |
| 65 | + |
| 66 | +If you prefer to manually set up provisioning, follow [this guide from Bitrise](https://devcenter.bitrise.io/en/code-signing/ios-code-signing/managing-ios-code-signing-files---manual-provisioning.html) instead. |
| 67 | + |
| 68 | +## Setup Code Signing for Android |
| 69 | + |
| 70 | +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](#prerequisites)). |
| 71 | + |
| 72 | +Bitrise lets you store your Android keystore in the build project. Follow [this guide from Bitrise](https://devcenter.bitrise.io/en/code-signing/android-code-signing/uploading-android-keystore-files-to-bitrise.html) to upload and store the keystore. |
| 73 | + |
| 74 | +## Adjust Workflow |
| 75 | + |
| 76 | +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. |
| 77 | + |
| 78 | +Any additional workflows that may have been created can be removed. Select the workflow from the dropdown and click **Properties** > **Delete workflow**. |
| 79 | + |
| 80 | +### Add Missing npm Command |
| 81 | + |
| 82 | +Add a missing npm command by doing the following: |
| 83 | + |
| 84 | +1. Add a new step after the step "Run npm command". |
| 85 | +1. Choose **Run npm command** from the list of steps. |
| 86 | +1. Set the npm command with arguments to run to `run configure`. |
| 87 | +1. Save changes. |
| 88 | + |
| 89 | +### Remove Unneeded Operating System Targets |
| 90 | + |
| 91 | +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. |
| 92 | + |
| 93 | +For example, if you only target iOS, you can remove the actions **Install missing Androide SDK components** and **Android Build**. This will significantly speed up your builds and save credits. |
| 94 | + |
| 95 | +### Add Android Code Signing (Android only) |
| 96 | + |
| 97 | +To add Android code signing, do the following: |
| 98 | + |
| 99 | +1. Add a new step after the step **Android Build**. |
| 100 | +1. Choose **Android Sign** from the list of steps. |
| 101 | +1. Save changes. |
| 102 | + |
| 103 | +Bitrise will use the uploaded keystore to sign the *.apk*. |
| 104 | + |
| 105 | +### Add Cocoapods Install (iOS only) |
| 106 | + |
| 107 | +To add Cocoapods install on iOS, do the following: |
| 108 | + |
| 109 | +1. Add a new step before the step **Xcode Archive**. |
| 110 | +1. Choose **Run CocoaPods install** from the list of steps. |
| 111 | +1. Set Workdir to `$BITRISE_SOURCE_DIR/ios` |
| 112 | +1. Save changes. |
| 113 | + |
| 114 | +This step will install the dependencies required for iOS. |
| 115 | + |
| 116 | +### Add iOS Code Signing (iOS Only) |
| 117 | + |
| 118 | +1. Add a new step before the step **Xcode Archive** (after Run CocoaPods install). |
| 119 | +1. Choose **Manage iOS Code Singing** from the list of steps. |
| 120 | +1. Save changes. |
| 121 | + |
| 122 | +Bitrise will use the provided iOS Signing information to sign the iOS app. |
| 123 | + |
| 124 | +After these changes, your workflow should look like this (if you target both operating systems): |
| 125 | + |
| 126 | +{{< figure src="/attachments/refguide/mobile/distributing-mobile-apps/building-native-apps/bitrise/select-repository.png" alt="Completed workflow" width="350" class="no-border" >}} |
| 127 | + |
| 128 | + |
| 129 | +## Build Your App |
| 130 | + |
| 131 | +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. |
| 132 | + |
| 133 | +When building, you can follow the build output and watch for progress and potential problems being reported there. |
| 134 | + |
| 135 | +To set up automatic builds after running **Build Native App**, follow these steps: |
| 136 | + |
| 137 | +1. Open the **Workflow Editor** of your build project. |
| 138 | +1. Open the **Triggers** page. |
| 139 | +1. Click **Add push trigger**. |
| 140 | +1. Select **Push branch** for **Condition 1** and change the **Push** branch to `master`. |
| 141 | +1. Select the **deploy** workflow and confirm. |
| 142 | + |
| 143 | +Now, every time some runs **Build Native App** to update the application bundle, a new build will be triggered in Bitrise. |
0 commit comments