See the general information on build configs.
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.
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.
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
.
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.
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.
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.
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).
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.