Lorixen.
EN

Separate dev, staging and production builds of your app

Short answer: If testers keep overwriting the live app with test builds, or a staging build accidentally talks to the production database, set up separate build variants: development, staging and production. Give each its own app ID or bundle identifier, its own name and icon, and its own API address and keys. Android does this with build types and product flavours, Flutter with flavours, and Expo with an APP_VARIANT setting in a dynamic config. Then all three can sit on one phone without getting mixed up.

The problems one build causes

Many small business apps start with a single build configuration. As soon as you have testers, a staging server and a live app, trouble follows:

  • A tester installs a test build and it replaces the real app on their phone, along with its login and data.
  • Someone forgets to switch the API address, and a test build places real orders against the live system.
  • Analytics and crash reports mix test sessions with real customers.
  • Push notifications meant for testers reach real users, or the other way round.
  • Nobody can tell from the icon which version is installed.

Each of these comes down to one cause: the app has no built-in idea of which environment it belongs to.

What a build variant is

A build variant is a version of the app produced from the same code with different settings. Common differences:

  • App identifier. The Android application ID and iOS bundle identifier decide whether two builds are "the same app". Different identifiers mean both can be installed at once.
  • Display name and icon, such as "Shop (Staging)" with a coloured badge.
  • API address and keys for the matching backend.
  • Analytics, crash reporting and push configuration, pointed at separate projects or keys.
  • Feature switches, such as debug menus only in development builds.

Expo's guide on app variants states the key requirement clearly: each variant needs a unique Android application ID and iOS bundle identifier so they can be installed side by side on one device.

Android: build types and product flavours

Android's build documentation explains that you don't configure variants directly. Instead you configure build types and product flavours, and Gradle combines them into variants.

  • Build types usually cover debug and release. The documentation's sample adds an applicationIdSuffix for the debug type and creates a "staging" build type initialised from debug's settings.
  • Product flavours describe different versions of the app, such as staging and production, or free and paid. They support the same properties as the default configuration, so each can set its own ID, name and values.

Each combination, for example stagingRelease, becomes a variant you can build and install.

Flutter flavours

Flutter supports flavours that map to Android flavours and iOS schemes. Its documentation shows running a specific one with flutter run --flavor staging. You'll typically also pass a separate entry file or compile-time values for API addresses, and set up a matching scheme and configuration on the iOS side.

Expo and React Native

Expo's tutorial uses a dynamic app.config.js that reads an APP_VARIANT environment variable and sets the app name, bundle identifier and package name accordingly, with build profiles defining the value for development, preview and production builds. Bare React Native projects can use Android flavours and iOS schemes directly.

iOS: schemes and configurations

On iOS, the usual approach is separate build configurations (such as Debug, Staging and Release) and a scheme for each, with settings files defining the bundle identifier, display name and other values per configuration. Each identifier needs its own entry in your developer account, and features like push notifications must be enabled for each.

Keep secrets and settings out of code

  • Store API addresses and non-secret keys per variant in configuration files or build settings, not scattered through the code.
  • Remember that anything shipped in an app can be extracted. Keys for third-party services should be the restricted, client-side kind, and anything truly secret should stay on your server.
  • Use separate projects or apps in analytics, crash reporting and push services for staging and production, so data stays apart.

Make the environment obvious

  • Give non-production builds a different icon or banner.
  • Show the environment and version on the login or settings screen.
  • In staging, use test payment keys and clearly fake sample data.

Wiring it into CI and distribution

Build each variant in your pipeline from the same commit: staging builds go to internal testers, production builds go to the stores. Tester tools such as TestFlight and Play's internal testing tracks can carry the staging app under its own identifier, so testers install it alongside the live app.

Common slip-ups

  • Forgetting deep links and universal links per variant, so a staging email link opens the live app.
  • Sharing one push notification setup across variants, which sends test pushes to real customers.
  • Copying the production config file into staging during a hurried release.
  • Leaving debug menus on in a build that later gets promoted to production.

A worked example

Picture a hypothetical Waterford grocery delivery start-up whose testers kept losing their real accounts when test builds replaced the live app. Worse, one test build had sent orders to the live system. The developer created staging and production flavours on Android and matching schemes on iOS, each with its own identifier, name, icon badge, API address and analytics project. Testers now have both apps on their phones, staging orders go to the staging server, and the settings screen shows the environment name.

FAQ

Do I need three variants?

Many small teams manage with two: staging and production. Add development if developers need local server settings.

Does each variant need its own store listing?

Only the production app is published publicly. Staging builds go through internal testing channels.

Will separate identifiers affect sign-in with Apple or Google?

Each identifier may need its own registration with those services. Check each provider's setup.

Can I switch environments inside one build instead?

You can, with a hidden menu, but separate builds are safer because a production build can't accidentally point at staging.

If your app's test and live versions keep getting mixed up, tell us how it's built and we'll help set up proper variants.

Sources

WhatsAppBook a call