> For the complete documentation index, see [llms.txt](https://playing-with-flutter.gitbook.io/flutter-production-flavor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://playing-with-flutter.gitbook.io/flutter-production-flavor/config-build-flavor-on-ios.md).

# Config Build Flavor on IOS

1. Click on the Runner, click the + button, choose duplicate "Debug Configuration", and change the name to "Debug-Nightly".

![](/files/euOojJOnXnqdcWVuT1RP)![](/files/dxPr87Fs4RHvi7SUlCPd)

2. Create New Scheme, named "Nightly" with "target Runner". After that edit scheme with "Build Configuration" in "run, test, analyze" to "Debug-Nightly".![](/files/JpK74vago4VJmpTMO6E1)![](/files/p8ufaaQTpDOhybmdtRNV)![](/files/bnILPEfQ5nH1E8qgbC7O)
3. Change "Product bundle identifier" and "Product name" for every flavor.

![](/files/qk3PDkbpDKkbehwSz42y)![](/files/JsVVPzsIxYHlAsKxXMJl)

4. With another variable like the "Google map API" key. Define a variable in user-defined, and change the value for each flavor

![](/files/nTsT2gXzWRznY6bIUZlL)

## Add a file for each environment

an example is add GoogleService-Info.plist&#x20;

1. Copy to project file like this:&#x20;

![](/files/JJsh1EeqbGuDFQ2oKO0q)

2. Select target Runner, and tab Build Phases, click + button, edit the name of the script to what you want.&#x20;

![](/files/1YIHaLblv24dtuw5lfga)

3. This script means copying the file to the right path when we build with a flavor.

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash">the # Type a script or drag a script file from your workspace to insert its path.

environment="Nightly"

# Regex to extract the scheme name from the Build Configuration
# We have named our Build Configurations as <a data-footnote-ref href="#user-content-fn-1">Debug-Nightly, Debug-Staging, Debug-Production</a> etc.
# Here, Nightly and Staging, Production are the scheme names. This kind of naming is required by Flutter for flavors to work.
# We are using the $CONFIGURATION variable available in the XCode build environment to extract 
# the environment (or flavor)
# For eg.
# If CONFIGURATION="Debug-Nightly", then environment will get set to "<a data-footnote-ref href="#user-content-fn-1">Nightly</a>".
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
  environment=${BASH_REMATCH[1]}
fi

echo $environment

# Name and path of the resource we're copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}

# Make sure GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}"
if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
  echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
  exit 1
fi

# Get a reference to the destination location for the GoogleService-Info.plist
# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"

# Copy over the prod GoogleService-Info.plist for Release builds
cp "${GOOGLESERVICE_INFO_FILE}" "${PLIST_DESTINATION}"
</code></pre>

Change FLUTTER\_TARGET in User-Defined for each environment.&#x20;

**staging**: lib/main\_stg.dart\
**nightly**: lib/main\_nightly.dart\
**production**: lib/main\_production.dart

&#x20;

That's all you need to do.

[^1]:
