iOS Firebase Crash Reporting - Error running build

2019-04-24 04:58发布

问题:

I get the following error when running the script to upload symbol files (everytime I try and build my project):

upload-sym-util.bash:351: error: symbolFileUploadLocation: The API Key and the authentication credential are from different projects.

Here is my build script:

if [ "$CONFIGURATION" == "Debug" ]; then
    GOOGLE_APP_ID=<app-id>
    "${PODS_ROOT}"/FirebaseCrash/upload-sym "${SRCROOT}"/<app>/Firebase/CrashReportingKey-Dev.json
else
    GOOGLE_APP_ID=<app-id>
    "${PODS_ROOT}"/FirebaseCrash/upload-sym "${SRCROOT}"/<app>/Firebase/CrashReportingKey.json
fi

Things I've done/checked:

  1. The GOOGLE_APP_ID and CrashReportingKey*.json are associated with the same project.
  2. My GoogleService-Info*.plist files have the API_KEY field.
  3. Checking "Run script only when installing" box, which allows me to run the app, but doesn't actually run the script in a development environment. So crashes are sent to Firebase, but they aren't symbolicated.

I'm open to any ideas. Thanks!

回答1:

You are correct that there's no way to override the GoogleService-Info.plist. However there's still a way to override the pieces of information the upload script uses from that file.

  1. Open the GoogleService-Info.plist corresponding to the .json.
  2. Search for GOOGLE_APP_ID and API_KEY.
  3. Adjust the build script like so:

    export FIREBASE_APP_ID=<GOOGLE_APP_ID>
    export FIREBASE_API_KEY=<API_KEY>
    
    "${PODS_ROOT}"/FirebaseCrash/upload-sym "ServiceAccount.json"
    

In your case, your final script should look something like:

    if [ "$CONFIGURATION" == "Debug" ]; then
        export FIREBASE_APP_ID=<app-id>
        export FIREBASE_API_KEY=<API_KEY for dev>
        "${PODS_ROOT}"/FirebaseCrash/upload-sym "${SRCROOT}"/<app>/Firebase/CrashReportingKey-Dev.json
    else
        export FIREBASE_APP_ID=<app-id>
        export FIREBASE_API_KEY=<API_KEY for release>
        "${PODS_ROOT}"/FirebaseCrash/upload-sym "${SRCROOT}"/<app>/Firebase/CrashReportingKey.json
    fi


回答2:

I resolved :

in terminal : rm $HOME/Library/Preferences/com.google.SymbolUpload*

Xcode : Product -> Clean



回答3:

The issue is with the name of GoogleService-Info.plist file.

In my project, I had the following files:

  • GoogleService-Info.plist
  • GoogleService-Info-Dev.plist
  • CrashReportingKey.json
  • CrashReportingKey-Dev.json

Firebase Crash Reporting upload script always looks for a file named GoogleService-Info.plist exactly. Since it found one, and I was telling the script to use CrashReportingKey-Dev.json, it threw the project mismatch error.

From my research, there is no way to tell the Firebase Crash Reporting upload script which *Info.plist file you want to use, so I have decided to only upload symbol files for release builds, which is fine.

My run script is now the following, and works as it should.

if [ "$CONFIGURATION" == "Release" ]; then
    GOOGLE_APP_ID=<app-id>
    "${PODS_ROOT}"/FirebaseCrash/upload-sym "${SRCROOT}"/<app>/Firebase/CrashReportingKey.json
fi

I then removed CrashReportingKey-Dev.json from my project.



回答4:

In my case, I had to reset my OAuth credentials by running this command : rm $HOME/Library/Preferences/com.google.SymbolUpload*

as described here : https://firebase.google.com/docs/crash/ios

Works fine for me now !



回答5:

I have this error today. And I found this config, simply replace this GOOGLE_APP_ID with the value in your GoogleService-Info.plist

View image here, sorry I don't have permission to post image Replace GOOGLE_APP_ID