Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prongbang/6f5c74ecb38fc88e1f90761e5dc7fb7f to your computer and use it in GitHub Desktop.
Save prongbang/6f5c74ecb38fc88e1f90761e5dc7fb7f to your computer and use it in GitHub Desktop.
A shell script to selectively copy your GoogleService-Info.plist into your app bundle based on the current build configuration.
if [ "${CONFIGURATION}" == "Debug-Production" ] || [ "${CONFIGURATION}" == "Release-Production" ];
then
cp "${PROJECT_DIR}/Runner/Firebase/Production/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Production plist copied"
elif [ "${CONFIGURATION}" == "Debug-Uat" ] || [ "${CONFIGURATION}" == "Release-Uat" ];
then
cp "${PROJECT_DIR}/Runner/Firebase/Uat/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Uat plist copied"
elif [ "${CONFIGURATION}" == "Debug-Develop" ] || [ "${CONFIGURATION}" == "Release-Develop" ];
then
cp "${PROJECT_DIR}/Runner/Firebase/Develop/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Development plist copied"
elif [ "${CONFIGURATION}" == "Debug-Sit" ] || [ "${CONFIGURATION}" == "Release-Sit" ];
then
cp "${PROJECT_DIR}/Runner/Firebase/Sit/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Mock plist copied"
fi
# Name of the resource we're selectively copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
# Get references to dev, sit, uat, prod versions of the GoogleService-Info.plist
# NOTE: These should only live on the file system and should NOT be part of the target (since we'll be adding them to the target manually)
GOOGLESERVICE_INFO_DEV=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Develop/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_UAT=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Uat/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_SIT=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Sit/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PROD=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Production/${GOOGLESERVICE_INFO_PLIST}
# Make sure the dev version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_DEV}"
if [ ! -f $GOOGLESERVICE_INFO_DEV ]
then
echo "No Development GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi
# Make sure the sit version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_SIT}"
if [ ! -f $GOOGLESERVICE_INFO_SIT ]
then
echo "No SIT GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi
# Make sure the uat version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_UAT}"
if [ ! -f $GOOGLESERVICE_INFO_UAT ]
then
echo "No UAT GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi
# Make sure the prod version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_PROD}"
if [ ! -f $GOOGLESERVICE_INFO_PROD ]
then
echo "No Production 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
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
if [ "${CONFIGURATION}" == "Debug-Production" ] || [ "${CONFIGURATION}" == "Release-Production" ];
then
echo "Using ${GOOGLESERVICE_INFO_PROD}"
cp "${GOOGLESERVICE_INFO_PROD}" "${PLIST_DESTINATION}"
elif [ "${CONFIGURATION}" == "Debug-Uat" ] || [ "${CONFIGURATION}" == "Release-Uat" ];
then
echo "Using ${GOOGLESERVICE_INFO_UAT}"
cp "${GOOGLESERVICE_INFO_UAT}" "${PLIST_DESTINATION}"
elif [ "${CONFIGURATION}" == "Debug-Develop" ] || [ "${CONFIGURATION}" == "Release-Develop" ];
then
echo "Using ${GOOGLESERVICE_INFO_DEV}"
cp "${GOOGLESERVICE_INFO_DEV}" "${PLIST_DESTINATION}"
elif [ "${CONFIGURATION}" == "Debug-Sit" ] || [ "${CONFIGURATION}" == "Release-Sit" ];
then
echo "Using ${GOOGLESERVICE_INFO_UAT}"
cp "${GOOGLESERVICE_INFO_UAT}" "${PLIST_DESTINATION}"
fi
@prongbang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment