Skip to content

Supporting Multiple Environments

Neil Horton edited this page Apr 5, 2016 · 2 revisions

Often in projects we want to do things slightly differently depending on what environment we are in. We can support this in fastlane by creating multiple .env files. A typical project setup will include the following .env files

  • .env.prod
  • .env.stage
  • .env.uat
  • .env.test

Fastlane will first load all the environment variables in the .env.default file before loading all environment variables in an environment variable passed to fastlane. this means we can still define any variables that are common across environments in our .env.default file. If a environment variable is defined in both the .env.default file and a .env file passed to fastlane the passed value will overwrite the default one.

We can call fastlane passing a .env file like so

$ fastlane test --env prod

Note that we just type the text after the second . we dont need the .env.

###Setting the app bundle identifier based on environment

A handy trick if we want to set the bundle ID differently based on which environment we are in is use the FL_UPDATE_PLIST_APP_IDENTIFIER environment variable declared in our .env files and replace the contents of our Appfile with the following

app_identifier = ENV['FL_UPDATE_PLIST_APP_IDENTIFIER']

Next: Defining your own lanes

Home

Clone this wiki locally