Could not get GOOGLE_APP_ID in Google Services file from build environment
Asked Answered
D

28

85

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.

Disillusion answered 12/7, 2019 at 12:5 Comment(4)
why does your file name have -test or -prdn in it?Favata
try removing themFavata
add one file at a timeFavata
make sure your project contains right GoogleService-Info.plist.Cupriferous
S
40

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

Star answered 12/7, 2019 at 15:32 Comment(5)
This is brilliant. This should be part of the FB documentation.Flareup
Don't create targets, use "build configurations" for this purpose.Sixtynine
@Sixtynine why? That sounds like the wrong tool for this taskAntechamber
@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.Sixtynine
Great reasoning! Thanks, @SixtynineAntechamber
E
41

If you use Xcode 15 (beta as of 2023), you might have updated your project with ENABLE_USER_SCRIPT_SANDBOXING.

The default is YES, and this will cause the issue with Crashlytics during archive.

Go to Build Settings > User Script Sandboxing > Set to No.

Execratory answered 14/8, 2023 at 14:50 Comment(3)
Thanks for this! Since the recommended setting for "User Script Sandboxing" is Yes, is there a different solution?Siderite
Yeap, I faced the issue after accepting Xcode suggested configurations to enable user script sandboxing. Thanks for the Tip.Panoptic
The settings in the solution at this link: https://mcmap.net/q/239112/-could-not-get-google_app_id-in-google-services-file-from-build-environment allowed me to use Crashlytics with "User Script Sandboxing" set to YES.Shellans
S
40

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

Star answered 12/7, 2019 at 15:32 Comment(5)
This is brilliant. This should be part of the FB documentation.Flareup
Don't create targets, use "build configurations" for this purpose.Sixtynine
@Sixtynine why? That sounds like the wrong tool for this taskAntechamber
@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.Sixtynine
Great reasoning! Thanks, @SixtynineAntechamber
E
38

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

Eudosia answered 11/10, 2019 at 8:23 Comment(4)
To 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.Manicdepressive
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 `Alienation
@huync I am getting error while running this script ${PODS_ROOT}/FirebaseCrashlytics/run What should be the input files path?Acidify
@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.Acidify
A
35

This worked for me:

Make sure you add the Xcode Crashlytics build phase after Copy Bundle Resources.

Aquatic answered 5/2, 2020 at 11:21 Comment(1)
I have tried all other ways. This answer helped me. Its working. Thanks @AquaticZennie
M
32

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}"
Mastiff answered 10/6, 2020 at 15:9 Comment(5)
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.Ries
This 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"Interbreed
Where did you add these in Build Phases?Gorge
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").Jarib
Update as of November 2022: This doesn't quite work for me, but if I remove the upload-symbols and instead put its parameters on the run command, it works. The run script passes all of its parameters to upload-symbols, and apparently throws this error if run has no parameters. At least for me.Maid
M
22

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
Mccool answered 19/6, 2020 at 5:38 Comment(2)
If you are using SPM then the script should be as follow: if [ "${CONFIGURATION}" = "Release" ]; then ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/HERE_SET_YOUR_PROJECT_NAME/SupportingFiles/GoogleService-Info/GoogleService-Info-Prod.plist else ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/HERE_SET_YOUR_PROJECT_NAME/SupportingFiles/GoogleService-Info/GoogleService-Info-Test.plist fiMireille
Slight typo in the SPM suggestion. Should be if [ "${CONFIGURATION}" = "Release" ]; then ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/HERE_SET_YOUR_PROJECT_NAME/SupportingFiles/GoogleService-Info/GoogleService-Info-Prod.plist else ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/HERE_SET_YOUR_PROJECT_NAME/SupportingFiles/GoogleService-Info/GoogleService-Info-Test.plist; fiBlowfly
H
10

In my case I created New Run Script Phrase above Compile Sources, that's why I always see

Could not get GOOGLE_APP_ID in Google Services file from build environment

When I moved Crashlytic's run script at the end of list bug was disappear. Please look the following screen shot: enter image description here

And article about it is here

Hyams answered 21/5, 2020 at 14:12 Comment(1)
I also followed the same steps, but still getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environment.Geomorphology
A
9

I use multiple configurations for several white-labelled apps. I added a User-Defined variable FIREBASE_SUFFIX and changed my script to the following:

${PODS_ROOT}/FirebaseCrashlytics/run -gsp ${PROJECT_DIR}/Firebase/GoogleService-Info-${FIREBASE_SUFFIX}.plist

NOTE: I use Carthage for firebase here: https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md. If you're this same setup, you should use something like this instead (replace the path to where you put your script files):

${PROJECT_DIR}/scripts/run -gsp ${PROJECT_DIR}/Firebase/GoogleService-Info-${FIREBASE_SUFFIX}.plist
Amadaamadas answered 7/7, 2020 at 12:24 Comment(0)
N
8

Another way is to make sure one plist keeps the original name GoogleService-Info.plist

Different targets meant more work to update CI for me.

This is valid for Xcode 11 at least, not tested on any other versions

Naples answered 4/10, 2019 at 7:34 Comment(1)
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.Ochoa
S
6

I was using new Firebase/Crashlytics which beta and getting error "No Google App ID or Google Services file provided" when I try to upload manually dSYMS

Here is command:

/path/to/pods/directory/FirebaseCrashlytics/upload-symbols
-gsp/path/to/GoogleService-Info.plist -p ios /path/to/dSYMs

Then I reliaze there should be space between "-gsp" and path to Google.plist after that It worked.

Suffragette answered 31/3, 2020 at 10:57 Comment(2)
what did you do with this command? Did you ran it in terminal? how do you get path to dSYMs?Nitwit
You can get dsym with itunnes connect in build section... and Yes I run in terminalSuffragette
A
6

The solution for me was removing the call to upload-symbols script.

One of the Crashlytics guides mentions you should add this:

${PODS_ROOT}/FirebaseCrashlytics/run
/path/to/pods/directory/FirebaseCrashlytics/upload-symbols  <- Not needed

I misinterpreted this... the run script already calls upload-symbols so there's no need to add a second call.

Accidie answered 27/9, 2020 at 5:43 Comment(3)
I am getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environmentGeomorphology
@ashwinitechnopurple make sure you added the plist from Firebase to your project and that it's also added to the correct app targetAccidie
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"Dominoes
W
5

Make sure in Xcode file explorer (i.e on the left side) "GoogleService-Info.plist" is showing. If not you have to drag and drop "GoogleService-Info.plist" in the Xcode panel.

In my case problem is I copy-pasted the file in the project location, due to this file reference is missing in the Project info.

Whacky answered 25/3, 2020 at 10:27 Comment(0)
S
4

Well all above answers purpose a possible solution for this issue, in my case GoogleService.plist file was missing from 'Copy Bundle Resources' by adding into it worked in my case..

To check the file goto

Project Directory >> Build Phases >> Copy Bundle Resources

add it add here if you find missing.

Southwest answered 12/5, 2020 at 3:16 Comment(0)
B
4

If these solutions provided above do not work, I solved mine by going to Build phases as shown on this image. Click on plus and add Google plist

Xcode screenshot solution

Batchelor answered 15/12, 2021 at 11:45 Comment(1)
Thanks it works! I have three environments (prod, uat, dev) all is working except prod i don't have any idea that GoogleService-info.plist need to be added on Copy Bundle Resources phaseStatant
I
3

Update Google and Firebase input files, look at the get started link below to fix this. For me, it works now in Xcode 15.3 and Firebase 10.24.0 (using SPM)

In build phases, search for run script Crashlytics and add the following code in input files:

enter image description here

${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}

${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}

${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist

$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/GoogleService-Info.plist

$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)

For more information, look here: https://firebase.google.com/docs/crashlytics/get-started?platform=ios

Individualism answered 26/4, 2024 at 2:31 Comment(1)
This is the proper answer. Follow the directions right on the Firebase get-started page, and you can keep the xcode build settings, and solve the errors. Thank you.Extranuclear
F
2

I had this issue because I didn't download GoogleService-Info.plist file from Firebase console.

If you have your project on Firebase but missing this file in Xcode, don't worry, you don't need to do the setup again from the beginning. Just go to:
Project Settings > General > Scroll down and in the "Your Apps" panel you will see the file and you can download it and import it in the Xcode project.

1

Fraga answered 12/10, 2022 at 13:31 Comment(0)
A
1

I was able to fix this by locate where is my GoogleService-Info.plist, copy it to ios folder in Flutter and run with this script

"$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"

Update: I found a better solution:

  • Just upgrade all firebase package to lastest version
  • Remove Crashlytics build script
  • Run flutter clean, flutter pub get
  • pod install (in ios folder)
Apostle answered 27/4, 2022 at 15:3 Comment(0)
C
1

This is what fixed it for me: I forgot to do this installation step of crashlytics before building my project. https://rnfirebase.io/#generating-ios-credentials

  • Using Xcode, open the projects /ios/{projectName}.xcodeproj file (or /ios/{projectName}.xcworkspace if using Pods).
  • Right click on the project name and "Add files" to the project,
  • Select the downloaded GoogleService-Info.plist file from your computer, and ensure the "Copy items if needed" checkbox is enabled.
Cicily answered 11/10, 2023 at 21:22 Comment(0)
H
1

This error occurred for me after integrating Firebase/Crashlytics

and I added GoogleService-Info.plist file by copy/pasting this file into iOS/[project-name] folder,

And it should've been added by right-clicking [project-name] in xCode and select Add file to [project-name]

This will add the file Build phases > Copy Bundle Resources

Harlanharland answered 18/3, 2024 at 11:47 Comment(0)
E
0

I had the same error, also due to the fact that I have multiple bundle identifier and therefore I have a build phase script called Firebase Script (that pinpoints to the correct GoogleService-Info.plist ) that was running after the Crashlytics script. The solution is to run Firebase Script before the Crashlytics script.

Externalization answered 1/6, 2020 at 13:3 Comment(0)
U
0

In my case I had a different name in my file, his name was GoogleService-Enterprise-Info.plis when I change it to the normal name GoogleService-Info.plist, IT WORK FINE !!

Unlive answered 14/9, 2020 at 21:43 Comment(0)
P
0

I faced the same issue for @react-native-firebase/crashlytics

In case you are facing this issue, you probably have missed the 'ios setup' instruction mentioned in below link. Please follow the instruction to fix the issue. https://rnfirebase.io/#generating-ios-credentials

Peel answered 18/10, 2020 at 18:21 Comment(0)
D
0

Just download from Settings of your projects and place for your correct target which you are running.

plist file

Deadman answered 21/1, 2021 at 12:38 Comment(0)
S
0

This error would be shown if there is a space in your project name or in the path of your project.

Read more in this GitHub Issue

Sanjuanitasank answered 25/2, 2021 at 12:1 Comment(1)
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.Issiah
P
0

Additionally to other answers..

I faced that problem with exact same error message and in my case everything was ok with file GoogleService-Info.plist except that it was genereated with wrong Bundle ID for application (it was changed in XCode much later than initial Firebase setup happened), so I had to create new app in Firebase Console with correct Bundle ID (it's not able to edit) and download new GoogleService-Info.plist

Polyptych answered 25/3, 2021 at 6:31 Comment(0)
M
0

If you are using one of the popular build scripts going around for handling multiple different environments, it is probably useful to know that you should use a different GoogleService-Info.plist destination based on the target platform:

// iOS
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app

// watchOS
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.appex

// macOS
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Resources
Mcknight answered 9/7, 2021 at 12:24 Comment(0)
F
-1

Ultimate guide:

  1. Assure that in Runner folder you have file GoogleService-Info.plist and it is attached in your project

  1. If you don't have this file go to Firebase Console, add you IOS app and download the GoogleService-Info.plist file, then add it to you project's Runner folder by XCode.

  2. If there is no such file in XCode but it exists physically in the folder then right click on Runner folder (in Runner project) -> Add files to Runner -> Select that file

  3. If you want to use multiple flavors add ENV_SUFFIX in Runner (target) -> Build Settings -> User-Defined (on the bottom) 4

  4. Still in the target's Runner change tab to Build Phases -> Press Plus button -> New Run Script Phase -> Name it as Copy GoogleService-Info.plist and add this line cp Runner/GoogleService-Info_${ENV_SUFFIX}.plist Runner/GoogleService-Info.plist IMPORTANT! This script has to be before Initialize Crashlytics step or any other Firebase related script (you can drag it to the top) enter image description here

  5. Add other GoogleService-Info.plist files with suffix for the env. In my case those would be the _dev _prod and _tst files from the first screen shot

  6. Enjoy multiflavor app

Fleda answered 30/7, 2022 at 13:38 Comment(0)
F
-5

Try downgrading, it worked for me! I used: 'Fabric', '1.9.0' 'Crashlytics', '3.12.0'

Fronnia answered 8/10, 2019 at 1:13 Comment(1)
Everybody should always use the latest version of stable software. Old version software can have critical bugs and security issues.Irvinirvine

© 2022 - 2025 — McMap. All rights reserved.