I am develop Flutter mobile app with Firebase.
I need separate Firebase environment for development and production.
I am follow this guide for setup.
Issue is when I implement google authentication for iOS because in Runner must copy REVERSED_CLIENT_ID from GoogleServices-Info.plist into Info.plist file.
I cannot just hardcode this REVERSED_CLIENT_ID into Info.plist because it is different for my development and production environments.
Is there way to specify variable in Info.plist to get correct REVERSED_CLIENT_ID for different environments?
I am use this script to copy correct GoogleServices-Info.plist:
if [ "${CONFIGURATION}" == "Debug-prod" ] || [ "${CONFIGURATION}" == "Release-prod" ] || [ "${CONFIGURATION}" == "Release" ]; then
cp -r "${PROJECT_DIR}/Runner/Firebase/Prod/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Production plist copied"
elif [ "${CONFIGURATION}" == "Debug-dev" ] || [ "${CONFIGURATION}" == "Release-dev" ] || [ "${CONFIGURATION}" == "Debug" ]; then
cp -r "${PROJECT_DIR}/Runner/Firebase/Dev/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Development plist copied"
fi
I look for answer everywhere but cannot find! I am completely block because of this.
Thanks!
I was able to solve this be creating a User-Defined variable that is environment specific and pull that variable into Info.plist
I setup my application to connect to two firebase projects (dev and prod) using instructions in this article: https://medium.com/@animeshjain/build-flavors-in-flutter-android-and-ios-with-different-firebase-projects-per-flavor-27c5c5dac10b
The thousand-foot summary is that you end up with a GoogleServices-Info.plist file for each dev and prod that is copied into the correct location at build time.
To set two REVERSE_CLIENT_IDS:
Open your project in XCode and go to the User-defined section and set the actual environment specific REVERSE_CLIENT_ID for each build type. Targets > Runner > Build Settings > Search "user" > User-Defined > GOOGLE_SERVICES_REVERSE_CLIENT_ID >
Debug-dev = com.googleusercontent.apps.{dev client-id}
Debug-prod = com.googleusercontent.apps.{prod client-id}
Profile-dev = com.googleusercontent.apps.{dev client-id}
Profile-prod = com.googleusercontent.apps.{prod client-id}
Release-dev = com.googleusercontent.apps.{dev client-id}
Release-prod = com.googleusercontent.apps.{prod client-id}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With