Mukesh Gami
Mukesh Gami

Reputation: 1230

Could not get GOOGLE_APP_ID in Google Services file from build environment

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.

Upvotes: 91

Views: 85073

Answers (28)

Pablo Ruan
Pablo Ruan

Reputation: 1771

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

Upvotes: 8

Hend El-Sahli
Hend El-Sahli

Reputation: 6742

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

Upvotes: 1

Helen2hang
Helen2hang

Reputation: 191

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.

Upvotes: 1

samwize
samwize

Reputation: 27363

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.

Upvotes: 46

stackich
stackich

Reputation: 5247

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

Upvotes: 2

Vivek Bansal
Vivek Bansal

Reputation: 1326

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.

Upvotes: 6

Mateusz Pietras
Mateusz Pietras

Reputation: 109

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

Upvotes: -1

Kyo Huu
Kyo Huu

Reputation: 578

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)

Upvotes: 1

yendis
yendis

Reputation: 1151

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

Upvotes: 5

budiDino
budiDino

Reputation: 13527

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

Upvotes: 0

Pavel Sokolov
Pavel Sokolov

Reputation: 104

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

Upvotes: 0

Yaman KATBY
Yaman KATBY

Reputation: 2013

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

Upvotes: 0

Manish
Manish

Reputation: 722

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

plist file

Upvotes: 0

huynguyen
huynguyen

Reputation: 7760

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

Upvotes: 39

Anupam Chaplot
Anupam Chaplot

Reputation: 1316

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

Upvotes: 0

Harout360
Harout360

Reputation: 939

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.

Upvotes: 6

Alex Vargas
Alex Vargas

Reputation: 1

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 !!

Upvotes: 0

Jacob
Jacob

Reputation: 1062

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

Upvotes: 9

Jay
Jay

Reputation: 275

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

Upvotes: 22

CmoiJulien
CmoiJulien

Reputation: 697

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

Upvotes: 32

Garolla
Garolla

Reputation: 1

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.

Upvotes: 0

Taras
Taras

Reputation: 1899

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

Upvotes: 10

Zeeshan Ahmed
Zeeshan Ahmed

Reputation: 864

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.

Upvotes: 4

Ucdemir
Ucdemir

Reputation: 3098

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.

Upvotes: 6

bizz84
bizz84

Reputation: 2272

This worked for me:

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

Upvotes: 36

Mauker Olimpio
Mauker Olimpio

Reputation: 1

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

Upvotes: -6

Aaron Thai Guy
Aaron Thai Guy

Reputation: 81

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

Upvotes: 8

Samuel Chavez
Samuel Chavez

Reputation: 786

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

Upvotes: 41

Related Questions