Could not get GOOGLE_APP_ID in Google Services file from build environment
Solution 1
This is one way you can do it, by having your projects environments separated by targets, by doing so you can then add your different plist files and just check the target that they belong to, that way when you compile the target it will take it's corresponding plist file
Another way to do it, or to look up how to do it, it's called multiple environments with firebase, here are some helpful links
Use different GoogleService-Info.plist for different build schemes
https://medium.com/rocket-fuel/using-multiple-firebase-environments-in-ios-12b204cfa6c0
Solution 2
This worked for me:
When install Crashlytic with Firebase, for multiple scheme, you can have error Could not get GOOGLE_APP_ID in Google Services file from build environment
. You can fix it by:
- In
Build Settings
, add a user define for file name inUser Defined
:
- In
Build Phases
, tap plus button,New Run Script Phase
above your Crashlytic build phase, and type this code to the text field. Remember to rename %YOUR_CUSTOM_PATH_TO_FOLDER% to your path to Plist files:
GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/%YOUR_CUSTOM_PATH_TO_FOLDER%/${FIREBASE_CONFIG_FILE}.plist"
BUILD_APP_DIR="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}"
GOOGLE_SERVICE_INFO_PLIST_TO="${BUILD_APP_DIR}/GoogleService-Info.plist"
cp "${GOOGLE_SERVICE_INFO_PLIST_FROM}" "${GOOGLE_SERVICE_INFO_PLIST_TO}"
Solution 3
This worked for me:
Make sure you add the Xcode Crashlytics build phase after Copy Bundle Resources.
Solution 4
I had this in my "Build Phases" and it's works
"${PODS_ROOT}/FirebaseCrashlytics/run"
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/MyApp/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
Solution 5
Our project only one target, but we need to use two Firebase config files GoogleService-Info-Prod.plist
and GoogleService-Info-Dev.plist
.
I had this in my "Build Phases" and it works.
if [ "${CONFIGURATION}" = "Release" ]; then
${PODS_ROOT}/FirebaseCrashlytics/run -gsp ${PROJECT_DIR}/RushCard/FirebaseConfig/GoogleService-Info-Prod.plist
else
${PODS_ROOT}/FirebaseCrashlytics/run -gsp ${PROJECT_DIR}/RushCard/FirebaseConfig/GoogleService-Info-Dev.plist
fi
Mukesh Gami
Updated on December 16, 2021Comments
-
Mukesh Gami over 2 years
For setting up firebase i am using two config 1.GoogleService-Info-test.plist, 2.GoogleService-Info-prdn.plist for UAT and Production. For installing crashlytics using firebase i have followed firebase documentation https://firebase.google.com/docs/crashlytics/get-started?authuser=1#ios. But when i try to run, it throws error in build phase while running script.
I tried without changing config file name and it worked.
Error msg at build phase while running fabric run script "Could not get GOOGLE_APP_ID in Google Services file from build environment".
Can anyone suggest better solution to achieve my requirement.
-
barrylachapelle almost 5 yearsThis is brilliant. This should be part of the FB documentation.
-
Edgar Froes over 4 yearsEverybody should always use the latest version of stable software. Old version software can have critical bugs and security issues.
-
Romano over 4 yearsHow can you be sure it will bind the Dsym to the relevant App then ? GOOGLE_APP_ID are different in the plist files if you have one bundle Id for Test and one for Prod.
-
Ollikas over 4 yearsTo make it consistent :
GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/%YOUR_CUSTOM_PATH_TO_FOLDER%/${FIREBASE_CONFIG_FILE}.plist" BUILD_APP_DIR="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" GOOGLE_SERVICE_INFO_PLIST_TO="${BUILD_APP_DIR}/GoogleService-Info.plist" cp "${GOOGLE_SERVICE_INFO_PLIST_FROM}" "${GOOGLE_SERVICE_INFO_PLIST_TO}"
But this solution really works for multiple scheme sharing same target with different bundle ids as well. -
Jerry Okafor about 4 yearsI am getting the following error :
unexpected EOF while looking for matching
"' ` and ` syntax error: unexpected end of file Command PhaseScriptExecution failed with a nonzero exit code ` -
Anirudha Mahale about 4 yearswhat did you do with this command? Did you ran it in terminal? how do you get path to dSYMs?
-
Ucdemir about 4 yearsYou can get dsym with itunnes connect in build section... and Yes I run in terminal
-
venky about 4 years@huync I am getting error while running this script ${PODS_ROOT}/FirebaseCrashlytics/run What should be the input files path?
-
venky about 4 years@Ollikas if you have faced the same issue & solved. please let know what is the input files path? I am getting the same error while running the script.
-
Honghao Zhang about 4 yearsAdding
-gsp
and-p
works for me. I moved theGoogleService-Info.plist
to a different direcotry, so I have to use-gsp
to specify the location. -
ashwini technopurple over 3 yearsI am getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environment
-
ashwini technopurple over 3 yearsI also followed the same steps, but still getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environment.
-
Harout360 over 3 years@ashwinitechnopurple make sure you added the plist from Firebase to your project and that it's also added to the correct app target
-
DanSkeel over 3 yearsDon't create targets, use "build configurations" for this purpose.
-
Ky - over 3 years@DanSkeel why? That sounds like the wrong tool for this task
-
DanSkeel over 3 years@BenLeggiero because targets are designed for completely different apps (e.g. watch app), and not for configurations of same app. Thats why they have
build configurations
for this purpose. Main downside of this approach - inpbxproj
file for each source file you get <numberOfTargets> duplicate lines that increase the complexity of resolving conflicts. You can add user defined build setting with a name of the config file and use it in code to get proper file depending on build configuration. -
Ky - over 3 yearsGreat reasoning! Thanks, @DanSkeel
-
Max Cruz over 3 yearsThis is my choosen solution. I use the CONFIGURATION variable to resolve the target like this:
PLIST="${PROJECT_DIR}/${TARGET_NAME}/Environment/${CONFIGURATION}
/GoogleService-Info.plist" -
GraSim about 3 yearsYou're a star Andrea! Thanks, Grace
-
Argus about 3 yearsThanks, but this didn't help for me. In my case there is no spaces in path to the project, but still having this error.
-
thecoolmacdude over 2 yearsWhere did you add these in Build Phases?
-
markhops about 2 yearsFor Flutter users, I was able to make this work by going to XCode -> "Project Navigator" tab -> Runner -> highlight the Target "Runner" -> "Build Phases" tab -> find the "[firebase_crashlytics] Crashlytics Upload Symbols" step, and change it to
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --flutter-project "$PROJECT_DIR/firebase_app_id_file.json" -gsp "$PROJECT_DIR/GoogleService-Info.plist" -p ios "$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME"
(previously it was"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --flutter-project "$PROJECT_DIR/firebase_app_id_file.json"
). -
Sainath A about 2 yearsThis worked for me. I removed this below line:
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --flutter-project "$PROJECT_DIR/firebase_app_id_file.json"
And added this as the first line:"$PODS_ROOT/FirebaseCrashlytics/run"