Creating Environment Specific Configurations
Platforms: iOS, Android
Many software development teams utilize different environments during the software development lifecycle. Configuration may differ between environments, such as bundle IDs, deep-link schemes, or icons and splash screens.
The Capacitor configuration file handles high-level options for Capacitor tooling and plugin configuration. iOS schemes and Android product flavors allow developers to provide differing app values for different environments. By combining the two, developers can use the Capacitor CLI to build apps for different environments.
This guide will walk you through setting up a QA environment configuration alongside the default environment configuration provided out-of-the-box. To demonstrate differences between each environment, the app name and bundle ID will differ between the two.
Prepare a Capacitor App
You will need a Capacitor app with both iOS and Android platforms added. If you have an existing Capacitor app with both platforms added, skip this section.
Depending on your preference, you can either add Capacitor to an existing web application or create a new Capacitor application with the Ionic Framework.
The Capacitor app must use TypeScript for configuration. This guide uses capacitor.config.ts
to dynamically export different configurations.
Before adding any native platforms to the project, you must build the Capacitor App at least once.
npm run build
Once built, you can add the platforms.
npm install @capacitor/ios @capacitor/android
npx cap add ios
npx cap add android