Skip to content

Latest commit

 

History

History
68 lines (41 loc) · 3.15 KB

build-configs.md

File metadata and controls

68 lines (41 loc) · 3.15 KB

Build Configs (native)

What are build configs and which build configs are available?

See the general information on build configs.

Using a Build Config

Build configs are used in two different places: In the javascript code during runtime and in gradle and XCode during the build process. Therefore, the build config has to be defined when compiling the javascript bundle AND when building the native container.

Runtime (Javascript)

For each build config there is a script in the package.json to ease the process of starting the packager:

yarn start:<build config name>

For the standard development build config integreat-test-cms there is also the shortcut yarn start.

To access the values of the build config import buildConfig.js.

Gradle (Android Build)

For each build config there is a script in the package.json to ease the process of building and installing the app on android:

yarn android:<build config name>

For the standard development build config integreat-test-cms there is also the shortcut yarn android.

To build integreat, malte and aschaffenburg in production mode, use the commands yarn android:integreat:production, yarn android:malte:production, yarn android:aschaffenburg:production.

XCode (iOS Build)

To use a build config in XCode, select the corresponding xcscheme and hit run or archive as specified in the manual builds doc. Before running the app, make sure to start the packager with the right build config as specified above as the packager started by XCode does not select a build config per default.

Not doing this will lead to this error.

Technical Information

The concept and technical implementation of build configs is inspired by the library react-native-config. All conversions are done with the manage.ts script.

Javascript

To make the selected build config available in the javascript code, we map the non-existing module build-config-name to the right name constant in the corresponding build config directory in the build-configs workspace, e.g. this file for Integreat. This is done with a proxy in the metro config in the extraNodeModules prop.

To access the values of the build config use this method.

Native Containers

XCode

For XCode we use hard coded xcschemes Pre Actions that select and convert the right build config to xcconfig files. Xcconfig files use a simple <key> = <value> syntax XCode has built in support for (and uses them).

Gradle

For Gradle the build config matching the BUILD_CONFIG_NAME environment variable is converted to a .json file for better typing and error handling. In Gradle the logic behind this can be found here.