66

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.

Mukesh Gami
  • 970
  • 1
  • 8
  • 14

22 Answers22

38

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

Samuel Chavez
  • 728
  • 8
  • 11
  • 7
    This is brilliant. This should be part of the FB documentation. – barrylachapelle Sep 02 '19 at 20:24
  • 4
    Don't create targets, use "build configurations" for this purpose. – DanSkeel Nov 08 '20 at 16:26
  • @DanSkeel why? That sounds like the wrong tool for this task – Ky. Nov 19 '20 at 16:28
  • 7
    @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 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. – DanSkeel Nov 19 '20 at 19:02
  • 1
    Great reasoning! Thanks, @DanSkeel – Ky. Nov 20 '20 at 16:43
34

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

huync
  • 7,375
  • 5
  • 32
  • 46
  • 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. – Ollikas Mar 17 '20 at 15:23
  • 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 ` – Jerry Okafor Apr 01 '20 at 13:20
  • @huync I am getting error while running this script ${PODS_ROOT}/FirebaseCrashlytics/run What should be the input files path? – venky Jun 13 '20 at 11:50
  • @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. – venky Jun 13 '20 at 11:51
28

This worked for me:

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

bizz84
  • 1,472
  • 17
  • 24
28

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}"
CmoiJulien
  • 491
  • 7
  • 4
  • 1
    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. – Honghao Zhang Jun 27 '20 at 23:45
  • 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" – Max Cruz Jan 04 '21 at 10:55
  • Where did you add these in Build Phases? – thecoolmacdude Jan 20 '22 at 18:12
  • 3
    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"`). – markhops Apr 03 '22 at 19:40
16

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
Jay
  • 207
  • 2
  • 7
9

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

Taras
  • 1,107
  • 11
  • 25
7

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

  • 2
    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. – Romano Mar 05 '20 at 15:33
7

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
Jacob
  • 1,012
  • 8
  • 10
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.

Ucdemir
  • 2,573
  • 2
  • 24
  • 39
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.

Harout360
  • 789
  • 1
  • 7
  • 14
  • I am getting an error: Could not get GOOGLE_APP_ID in Google Services file from build environment – ashwini technopurple Oct 07 '20 at 03:50
  • @ashwinitechnopurple make sure you added the plist from Firebase to your project and that it's also added to the correct app target – Harout360 Oct 09 '20 at 18:36
  • 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"` – Sainath A May 01 '22 at 12:38
3

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 Xcode panel.

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

Vivek Bansal
  • 1,088
  • 10
  • 18
2

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.

Zeeshan Ahmed
  • 644
  • 6
  • 13
1

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

yendis
  • 155
  • 1
  • 7
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)
Kyo Huu
  • 444
  • 6
  • 12
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.

Garolla
  • 1
  • 1
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 !!

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

Anupam Chaplot
  • 724
  • 5
  • 20
0

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

plist file

Manish
  • 458
  • 6
  • 20
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

Yaman KATBY
  • 1,374
  • 7
  • 23
  • 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. – Argus Apr 09 '21 at 12:28
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

Pavel Sokolov
  • 104
  • 1
  • 6
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
budiDino
  • 12,178
  • 8
  • 92
  • 90
-4

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

  • 3
    Everybody should always use the latest version of stable software. Old version software can have critical bugs and security issues. – Edgar Froes Jan 25 '20 at 04:38