I am trying to build a flutter app on Codemagic. The app uses multiple firebase project so I have configured it accordingly. I am able to run all flavors both for android and iOS locally. The android build is success on Codemagic as well but the iOS build fails.
In the below screenshot you can see after reaching the Firebase setup run script file the iOS build fails
Code for my Firebase Setup file is
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
# 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}"
I am following https://medium.com/@animeshjain/build-flavors-in-flutter-android-and-ios-with-different-firebase-projects-per-flavor-27c5c5dac10b article for setup.
Here is another approach which I took as recommended by the Codemagic team
Instead of creating flavors,i uploaded my firebase
files to codemagic as environment variables. Everything works fine for android but the iOS build fails saying Could not get GOOGLE_APP_ID. I know many people have asked question regarding this on stack but none of them works for me as they are not related to code magic and instead dragging the file to Xcode manually.
I also did an SSH to check if the firebase file gets added to iOS folder and it does get added with the help of prebuild scripts but iOS build still fails.