I recently added Flutter Flavors to my Flutter project because I wanted production, staging, and development environments. I also wanted different Firebase projects for each flavor so I created a config folder with their own each individual folder for each Firebase Project GoogleService-Info.plist files
I also added this Build Phase Script in the Runner Target –
environment="default"
# Regex to extract the scheme name from the Build Configuration
# We have named our Build Configurations as Debug-dev, Debug-prod etc.
# Here, dev and prod 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-prod", then environment will get set to "prod".
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
Located here in the Build Phases (the script called ‘Copy GoogleService-Info.plist to the correct location’
I know that these files are not getting used because I have another GoogleService-Info.plist from before I was using Flutter Flavors and only had one Firebase Account.
When I delete the original GoogleService-Info.plist (Not the one’s from the config file) my flutter project complains that it cannot find the GoogleService-Info.plist file. Not sure why this is happening.
I followed this
Medium Tutorial –
https://medium.com/@animeshjain/build-flavors-in-flutter-android-and-ios-with-different-firebase-projects-per-flavor-27c5c5dac10b
and this YouTube video –
https://www.youtube.com/watch?v=Vhm1Cv2uPko







