Welcome to the Make it Native App repository! The Make it Native app is a powerful tool designed to streamline the development process for Mendix Studio Pro users. This app allows you to run your Mendix mobile applications directly on your device without needing a build, facilitating a smoother and faster development cycle.
- Introduction
- 1.1 Getting started
- 2 Building your Application
- 2 Building
- 3 Set Up your Developer Environment
- 4 Google Maps Configuration
- 5 FAQ
- 6 Contribution Guide
- 7 Sample Apps
- 8 Generating iOS & Android Native Bundles and Assets {#generate-native-bundles}
- License
The Make It Native (MIN) app allows you to test native apps in development with ease. We have also made it open source, allowing you to change it depending on your needs. Depending on your Mendix version, you can use the MIN app in one of two ways:
- Long Term Support (LTS) Studio Pro Version — If you want to use the Make It Native app to test your native apps, you must choose a MIN version compatible with your LTS version of Studio Pro.
- Non-LTS Studio Pro Version — If you choose use a non-LTS version of Studio Pro and still wish to use the MIN app, then you will have to manually build a version of the MIN that is compatible with your version of Studio Pro.
This guide explains how to complete the second bullet's task: build a MIN app compatible with a non-LTS Studio Pro version.
First things first, make sure you clone your repo and install necessary software:
- Clone the repository:
git clone https://github.com/mendix/make-it-native.git
- Navigate to the project directory:
cd make-it-native
- Install dependencies:
npm install
- Install pods:
cd ios && pod install
To ensure that you can build and run the Make it Native (MiN) application successfully, you need to use a version of the application that is compatible with your Mendix Studio Pro version. Our repository includes multiple branches, each compatible with different versions of Mendix Studio Pro. Follow these steps to switch to the appropriate branch and build the application.
First, confirm the version of Mendix Studio Pro you are currently using. You can find this information in the Mendix Studio Pro application under Help > About Mendix Studio Pro.
Based on your Mendix Studio Pro version, switch to the corresponding branch in our repository. Here are the branches available for different versions:
Studio Pro Version | Branch |
---|---|
Mendix Studio Pro 10.10.0 | mx/10.10.0 |
Mendix Studio Pro 10.9.0 | mx/10.9.0 |
Mendix Studio Pro 10.8.0 | mx/10.8.0 |
Mendix Studio Pro 10.7.0 | mx/10.7.0 |
Mendix Studio Pro 10.6.0 | mx/10.6.0 |
Mendix Studio Pro 10.5.0 | mx/10.5.0 |
Mendix Studio Pro 10.4.1 | mx/10.4.1 |
Mendix Studio Pro 10.3.1 | mx/10.3.1 |
Mendix Studio Pro LTS/9.24 | mx/lts/9.24 |
Mendix Studio Pro MTS/10.6 | mx/mts/10.6 |
Use the following Git command to switch branches:
git checkout <branch-name>
Replace <branch-name>
with the branch corresponding to your version of Mendix Studio Pro.
To build and run the native mobile app successfully, you must complete several setup steps related to external services like Firebase and Google Maps. Follow the instructions below carefully.
- Create a Firebase Project:
- Go to the Firebase Console and create a new project.
- Add your App to the Firebase Project:
- For Android, add an Android application and follow the website's instructions.
- For iOS, add an iOS application and follow the website's instructions.
- Download configuration files:
- For Android, download the google-services.json file.
- For iOS, download the GoogleService-Info.plist file.
- Place Configuration Files in Your Project:
- For Android, move the google-services.json file to the android/app directory.
- For iOS, move the GoogleService-Info.plist file to the ios/DeveloperApp directory.
Follow the instructions provided by Google here to obtain an API key.
Open your android/app/src/main/AndroidManifest.xml file and find the section with the placeholder {{GEO_API_KEY}}
. Replace {{GEO_API_KEY}}
with your actual Google Maps API key:
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY_HERE"/>
To run iOS Fastlane script containing an API key, define the variable GOOGLE_MAPS_API_KEY
before beta lane. If you run it manually in XCode, change the API key in the ApiKeys.xcconfig file.
Once you have completed the additional setup requirements, you can proceed with building your applications. You can use Fastlane to build the apps.
Fastlane is an all in one CI tool that automates the process of building and deploying apps. To install it, do the following:
- Install fastlane by gem
sudo gem install fastlane -NV
- Add these lines in
~/.bash_profile
or~/.zshrc
(point the version to version installed):export FASTLANE_PATH="/usr/local/lib/ruby/gems/2.6.0/gems/fastlane-2.134.0/bin" export PATH="$FASTLANE_PATH:$PATH"
For building iOS apps, Mendix uses Fastlane. Fastlane is an all in one continuous integration tool that automates building and deploying.
For building Android apps, the process is still manual.
iOS builds are produced via Fastlane.
The configuration for Fastlane resides in /ios/fastlane/Fastlane
. Currently three lanes are configured internal, build, and release:
- Internal should be used for internal test builds as in example detox
- Beta pushes the resulting
ipa
to Test Flight - Release creates a new release in App Store Connect
Currently submitting the app for review is a manual step, but this might change.
⚠️ For the Beta and Release lanes, before building, be sure to change the VERSION_NUMBER in theFastlane
config file manually.
To build your app for internal testing, do the following:
- Change directory into
/developerapp/ios
. - Run the
fastlane internal
command to build your app. - The output will reside in
/build/internal/output
, so grab your files from that directory.
Change the VERSION_NUMBER in the Fastlane
config file to your new version, then build:
- Change directory into
/developerapp/ios
. - Run the
fastlane beta
command.
The script will take considerable amount of time as it also waits for processing to finish, to release a TestFlight beta test.
Change the VERSION_NUMBER in the Fastlane
config file to the new version, then build:
- Change directory into
/developerapp/ios
. - Run the
fastlane release
command.
The script will take considerable amount of time as it also waits for processing to finish, to release a TestFlight beta test.
Android builds are made via Android Studio:
- Open Android Studio.
- Open
/app/build.gradle
and change theversionName
to the new version andversionCode
to an integer value higher than the last release build. - Select
Build -> Generate Signed Bundle / APK
. - Select the
APK
check box. - On the next screen add the signing certificate.
- Select
developerappRelease
from the build variants, and tickV1
andV2
Signatures. - Build your Android app.
iOS applications require XCode, so we assume you have the latest version installed and ready to use.
Mendix uses CocoaPods to manage the iOS dependencies, which you can set up as follows:
- To install CocoaPods on your system, run
sudo gem install cocoapods
. - To install NPM dependencies, run
npm i
. - Clean install the podfiles by running
npm run ios:clean-pod-install
- Install provision profile and certificates by running
npm run ios:dev
, then enter your machine password. - Open the project via the
*.xcworkspace
file (not thexcodeproj
).
From to time you must update the native dependencies. Therefore, it is important to re-install the node modules and CocoaPods in the following cases:
- After a branch switch
- If the app exhibits erratic or odd behavior
Set up your developer environment for Android as follows:
- Install a recent Android Studio version.
- Open the project in
developerapp/android
as existing project or import it as Gradle project. - Update or install a recent SDK.
- Install a recent NDK.
- Switch the Build Variant in Android Studio (on the lower-left side) to
developerappDebug
unless it has been selected by default. - Start a Gradle sync.
- If successful, the green play button should be usable.
To enable remote debugging, do the following:
- Fill in host with <your_ip>:8080 (you can use localhost:8080 if you are running in an emulator or simulator).
- Select Enable dev mode checkbox/switch.
- When the app loads, open the app menu:
- If you are running on a physical device: use a 3-tap long press or shake your device.
- If you are running on an iOS emulator: press {CTRL} + {CMD} + {Z}.
- If you are running on an Android emulator on Mac: press {CMD} + {M}.
- Select Enable remote debugging from the menu.
- After the Chrome screen pops up, change its URL to localhost:8083/debugger-ui/.
Building from source is required to be able to debug React Native specific code.
Building from source can be done as follows:
- Check out the React Native repo
https://github.com/facebook/react-native.git
. - Paste the Package folder into the developer app's node_modules/react-native folder.
- Toggle
BUILD_RN_FROM_SOURCE=true
ingradle.properties
. - Clean and build app.
You cannot use localhost
, as it points to the Android simulator instead of the host machine.
To work around this, do one of the following:
- Use
10.0.2.2:8080
as the URL. - Run
adb reverse tcp:8080 tcp:8080
andadb reverse tcp:8083 tcp:8083
from your console.
To configure Google Maps functionality, do the following:
- To run a iOS FastLane script containing an API key, please define the variable
GOOGLE_MAPS_API_KEY
before beta lane. If you run it manually in XCode, change the API key inApiKeys.xcconfig
file.
To configure Google Maps functionality, do the following:
- To run Android a FastLane script containing an API key, please define the variables
FIREBASE_API_KEY_1
andFIREBASE_API_KEY_2
before internal lane. This values can be find in the Firebase file when downloading it from the Firebase website. If you run it manually in Android Studio, change the API keys in thegoogle-services.json
file.
There are a number of reasons why syncing would fail. Please consult the sections below depending on your use case.
We are trying to keep master working, but something might go wrong from time to time. If a dependency is missing or was falsely important due to developer error, we recommend consulting the build logs. The build logs should point exactly to the offending files, allowing you to fix the issue and resync.
If the project explorer does not list any of the NPM modules imported, check for both of the following situations:
npm i
has not been run yet- Android Studio caches are not functioning as intended
To solve in the first case, simply run npm i
as directed above.
For the second case, do the following:
File -> Invalidate Caches / Restart
Build -> Clean Project
As a last resort, delete the following folders relatively to the project's directory:
- Delete the
.gradle
folder. - Delete the
.idea
folder. - Delete both
build
folders in/app
and/mendixNative
. - Restart android studio and open the project.
When building on windows, the NDK build step generates extremely long paths that might break the build. A possible indication of this problem is errors in the form of "can't find directory or file in c:\<extremely long path name>
".
To fix this issue, do the following:
- Open the top level
build.gradle
file. - Search for line
allProject { ... }
. - Add
buildDir = c:/tmp/${rootProject.name}/${project.name}
after the first{
.
From now on the output of the builds is being generated in the build directory provided. So if you are looking for the generated APKs, then look there.
For errors that point to the React Native Gradle files or native compilation, React Native probably cannot find your NDK installation.
The easiest way to fix it is to add the path to the NDK to your PATH
:
Open ~/.bash_profile
or ~/.zshrc
:
export ANDROID_NDK="~/Library/Android/sdk/ndk/*add-your-ndk-version-number*"
export PATH=$PATH:$ANDROID_NDK
For deeper information on the best contributions, see the following:
- See general recommendations located in the MIN repo's README.md.
- If the merge request contains changes that impact users, then the merge request should include an update to
CHANGELOG.ios.txt
orCHANGELOG.android.txt
For example
- We deprecated MxAgent. Use the Core.metrics() API instead.
- We upgraded the embedded database HSQLDB to version 2.6.1.
To update sample app bundles and assets, see the sections below for instructions based on platform.
In android > app > src > main > assets
(from here on referred to as (A)) there is a sampleapps.zip
file.
Once decompressed, you will find folders representing sample apps. Each folder's name can be arbitrary, but it must match up with an id
from sample_apps.json
in (A).
The file sample_apps.json
file describes each sample app and contains information for those sample apps. Follow the steps below
to update the Android developer app bundle and assets:
- Unzip
sampleapps.zip
. - Find the folder for the sample app you want to update — reference
sample_apps.json
. cd
to this folder.- In (A), replace
index.android.bundle
with the file located in Android Bundle. - In (A), delete all other folders (and any files) and replace with contents located in Android Assets.
- The app thumbnail can be updated by substituting the existing splash.png file located in the app's root folder.
- Zip the app folders by selecting all of them and then zip all app folders (rather than zipping the parent directory). The zipped folder should be called
sampleapps.zip
. Make sure that the root content of the.zip
is each sample app folder. - In (A), open
sample_apps.json
and bump the version.
See Generating iOS & Android Native Bundles and Assets for details on generating a project's bundles and assets.
In ios > DeveloperApp > SampleApps > Bundles
there are folders that represent each sample app.
The folder name can be arbitrary. The config.json
file describes each sample app, and each object's id
property matches the folder name and provides details about the sample app. Follow the steps below to update the iOS developer app bundle and assets:
- Find the folder for the sample app you want to update — reference
config.json
. cd
to this folder- Replace the
index.bundle
file with the updated one from iOS Bundle. Note: make sure to rename the filename to index.bundle, as it is usually index.ios.bundle. - Clean the contents of the
assets
folder. - Copy all content from iOS Assets into the
assets
folder.
See Generating iOS & Android Native Bundles and Assets for details on generating a project's bundles and assets.
If using Native Builder UI (which also creates native apps to use for testing), do the following to generate iOS & Android native bundles and assets:
- In Studio Pro, click App > Build Native Mobile App.
- Click Configure app for local building.
- (Build type) Select a disk location for the native app source code.
- (Build type) Disable GitHub and App Center cloud services.
- (Splash screens / App icon / Custom fonts) Use the default splash screen and app icons and no custom fonts (because we need the JavaScript bundle and project assets, this step isn't important but required).
- (App details) Select Portrait and Landscape for app's orientation selection.
- (App details) Select Phones and Tablets for app's Device targets selection.
- (App capabilities) Disable all capabilities.
- (App capabilities) If your project contains a widget or action that requires a Google API key, add it.
- (Configure app locally) Enter in a version number.
- (Configure app locally) Enter in a runtime URL — if you want to test the native app, enter an appropriate runtime URL.
- Click Configure locally.
The native app's source code will be in the disk location selected in step 3. In your Mendix Project directory, in deployment > native > bundle there will be both the Android and iOS bundles and assets.
To generate native bundles and assets while using Studio Pro in developer mode, do the following:
- Add
--enable-dev-mode
in the launch options for Studio Pro executable. - In the DEV menu in the topbar, under
NativeUI
clickNative Packager settings
then enable the native bundles to be created during deployment. - Run the Mendix project.
In your Mendix Project directory, in deployment > native > bundle you will find both the Android and iOS bundles and assets.
In your Mendix project folder you will find the files listed below depending on your platform.
In deployment > native > bundle > android > assets > index.android.bundle
In deployment > native > bundle > android > res > (all folders and files)
In deployment > native > bundle > iOS > index.ios.bundle
In deployment > native > bundle > iOS > assets > (all folders and files)
Make it Native is open source software licensed under the Apache-2 license.