Could not get GOOGLE_APP_ID in Google Services file from build environment

43,446

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

Sample Image

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 in User Defined:

Add file name for each scheme in User 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}" 

Add build phase

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
Share:
43,446
Mukesh Gami
Author by

Mukesh Gami

Updated on December 16, 2021

Comments

  • Mukesh Gami
    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
    barrylachapelle almost 5 years
    This is brilliant. This should be part of the FB documentation.
  • Edgar Froes
    Edgar Froes over 4 years
    Everybody should always use the latest version of stable software. Old version software can have critical bugs and security issues.
  • Romano
    Romano over 4 years
    How 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
    Ollikas over 4 years
    To make it consistent : GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/%YOUR_CUSTOM_‌​PATH_TO_FOLDER%/${FI‌​REBASE_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
    Jerry Okafor about 4 years
    I 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
    Anirudha Mahale about 4 years
    what did you do with this command? Did you ran it in terminal? how do you get path to dSYMs?
  • Ucdemir
    Ucdemir about 4 years
    You can get dsym with itunnes connect in build section... and Yes I run in terminal
  • venky
    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
    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
    Honghao Zhang about 4 years
    Adding -gsp and -p works for me. I moved the GoogleService-Info.plist to a different direcotry, so I have to use -gsp to specify the location.
  • ashwini technopurple
    ashwini technopurple over 3 years
    I am getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environment
  • ashwini technopurple
    ashwini technopurple over 3 years
    I also followed the same steps, but still getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environment.
  • Harout360
    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
    DanSkeel over 3 years
    Don't create targets, use "build configurations" for this purpose.
  • Ky -
    Ky - over 3 years
    @DanSkeel why? That sounds like the wrong tool for this task
  • DanSkeel
    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 - in pbxproj 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 -
    Ky - over 3 years
    Great reasoning! Thanks, @DanSkeel
  • Max Cruz
    Max Cruz over 3 years
    This is my choosen solution. I use the CONFIGURATION variable to resolve the target like this: PLIST="${PROJECT_DIR}/${TARGET_NAME}/Environment/${CONFIGURA‌​TION}/GoogleService-‌​Info.plist"
  • GraSim
    GraSim about 3 years
    You're a star Andrea! Thanks, Grace
  • Argus
    Argus about 3 years
    Thanks, 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
    thecoolmacdude over 2 years
    Where did you add these in Build Phases?
  • markhops
    markhops about 2 years
    For 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
    Sainath A about 2 years
    This 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"