We are building a Xamarin.Forms app targeting iOS and UWP. We have a requirement that the app should be available as separate installation for Staging and Production. Basically each environment has its own settings (server URLs, app configurations and so on), which are stored in an external Configuration.json
file. The main point is that in order to dynamically pick a correct Configuration.json
file for each environment, the app should not be re-built. We should build the app only once, and only change configurations. We were able to solve this problem for iOS
To support dynamic configurations for iOS, we did the following
- store all environment configuration files within the project like
StagingConfiguration.json
,ProductionConfiguration.json
. - Register separate application in iTunes connect per environment with its own bundle ID - e.g.
com.mycompany.app.staging
for staging,com.mycompany.app
for production - After the app is built and
ipa
file is generated, we usedfastlane
to resign the app with new bundle id and provisioning profile, something like this (we use Azure DevOps CI/CD pipeline for builds and release, this step is command line execution in the release pipeline, and references environment variables to do its job)
fastlane run resign ipa:"PATH_TO.ipa" signing_identity:"$(SigningIdentity)" bundle_id:$(BundleId) provisioning_profile:"$(provisioningProfile.secureFilePath)"
- And then simply upload the resigned pipeline to AppStore
- Within the app, we detect what's the bundle ID of the app, and based on that pick the correct configuration file
So, we are trying to find similar solution for UWP as well. The output package of the UWP app is a package like this QQPad.Mobile.UWP_0.39.0.0_x86_x64_arm_bundle.appxupload
. Probably, we will need to do one of the following to support our scenario
- Do the same as in iOS - create separate UWP app in the store, store multiple config files within the project, change the app's package name after the
appxupload
project is ready, and on the code side, detect the bundle ID and choose the right configuration file - Or, if possible, even better solution would be the following
- Do not create separate app, as it's cumbersome to manage, but rather create separate package flights within the same app hosting
- Instead of changing package name, be able to locate the configuration file within the
appxupload
and replace it with the config file of our choice - Repack the app and resign it
- Upload it to the correct package flight
Again, the main point is being able to dynamic pick or change the configurations without having to rebuild the app. Are there any utilities for UWP that are equivalent of fastlane
for iOS, which would also allow app bundle manipulations? Or I will have to do this manually? If so, how exactly?
how will the API understand whether the app is dev, staging or prod?
I think there should be a parameter there when posting the api. – Jack Hua