48

I'm trying to integrate Firebase Crashlytics into iOS my app, which has Firebase Crash Reporting enabled. I've followed the documentation here, but my build always fails when running the custom build phase:

"${PODS_ROOT}/Fabric/run"

The error in Xcode is the following:

error: Fabric: Configuration Issue

Fabric API key not valid. Your Fabric run script build phase should contain your API key: ./Fabric.framework/run INSERT_YOUR_API_KEY INSERT_YOUR_BUILD_SECRET

I do not have a Fabric API key and I suppose that they fabric keys should be taken care by the Firebase library. I have the Info.plist in my project, Firebase is fully functional, but I cannot get past the Fabric run phase. Any help on how to fix this is greatly appreciated!

Community
  • 1
  • 1
Lucas P.
  • 4,282
  • 4
  • 29
  • 50
  • The error message is clear, you have to get an API Key – Claudio Dec 18 '17 at 11:17
  • 3
    That's what I thought, but the documentation clearly states that you **do not need an API key**. I finally found the solution, the Fabric.app on OSX automatically sets your Fabric api key in the app-info.plit file, which the script reads, and fails if you do not provide it with one. Removing this form the info.plist, and the script just plainly works. – Lucas P. Dec 18 '17 at 11:22
  • 1
    I missed to add `FirebaseApp.configure()` in AppDelegate. After adding this, it worked perfectly. – Mohammad Zaid Pathan Jan 26 '19 at 19:40

7 Answers7

152

Finally figured it out, posting for anyone that might be baffled by the same problem.

If you've tried to install fabric via the OSX Fabric.app, or you were using Fabric Crashlytics in the past, then it will have added your Fabric API key to your Info.plist, which the Fabric initialization build script is trying to read (I guess).

After deleting the Fabric keys form the Info.plist the script works, without the need of any keys/params.

The Firebase docs should include a snippet warning on this.

Lucas P.
  • 4,282
  • 4
  • 29
  • 50
  • 1
    I had the exact same issue, and I followed your post and removed the API key. It works now. But, the Crashes are not logged on Firebase. Any Idea why it takes place ? – Illep Dec 19 '17 at 18:37
  • I had some issues as well using Crashlytics.sharedInstance().crash() (on Android though, it worked on iOS) so I would suggest creating an actual crash like this: `let nilVar: String? = nil nilVar!.isEmpty()` Let me know if the crash appears then (give it at least 5 minutes, although when it works crashes appear almost instantly). – Lucas P. Dec 19 '17 at 19:25
  • 1
    Sadly no. It doesn't get recorded in firebase. But it says that the crash has been uploaded . ` : [Firebase/Crash][I-CRA100002] Crashes uploaded successfully: ( 1e21a90b1c000000 )` – Illep Dec 19 '17 at 19:41
  • Are you other firebase services working (have you verified that your app is set up correctly)? Do you also have Firebase Crash Reporting enabled? You should remove the FirebaseCrash pod, since only one crash reporting library can be active at a time on iOS. – Lucas P. Dec 19 '17 at 20:27
  • In the console for `Users active in last 30 minutes` it says `1 user`, so i guess firebase has been configured correctly. What do you mean by `Firebase Crash Reporting enabled` ? I have it setup from console, but see no reports in it. Why should I remove `FirebaseCrash ` pod ? the doc says to install it – Illep Dec 19 '17 at 20:33
  • The Crashlytics docs [here](https://firebase.google.com/docs/crashlytics/upgrade-from-crash-reporting) states that when migrating from "Firebase Crash Reporting" to "Firebase Crashlytics" that you have to remove the "Firebase Crash Reporting" library. (for the reason I mentioned above). Try it and let me know. – Lucas P. Dec 20 '17 at 11:20
  • 3
    For my project, had to unlink Fabric from Crashlytics and had to do all of the above in order for the crash logs to appear in the Firebase Dashboard. This seems to be an issue for iOS only. – atodTechies Apr 09 '18 at 23:44
  • I have remove the keys from plist and also added the required script. But still showing the same error for key. – Gurjinder Singh Oct 30 '18 at 10:36
  • 3
    Boom! This worked for me! Just trying to clean up my project in preparation for the full changeover in 2019 – Christian Gossain Dec 21 '18 at 23:39
  • 3
    Hi All, I am migrating an iOS application from Fabric to Firebase and facing a similar issue. My question is "Do we need to delete Fabric Initialization(from `AppDelegate`) and Fabric Key(from `Info.plist`) or not?" If we delete it then `Firebase` is not getting the crashes. If we don't delete it then why do we need to add `Firebase` to the App? I mean by linking the app to `Firebase` we will get all the crashes. – NightWatcher Apr 18 '19 at 12:25
5

If you follow closely the Getting Started documentation, you might be in for some frustrations. Trust me. I had my share of that.

Now here's what I can share with you.

  1. If you previously had Fabric RunScript for that Target, then it's best if you delete that and create a new one, apply the GettingStarted instruction, and replace the $(INFOPLIST_PATH) with GoogleService-Info.plist.

  2. There should be no Fabric configuration on your Info.plist file anymore. It's this thing: <key>Fabric</key><dict>...</dict>. If you still have that, time to say goodbye and let go of those feelings or face this issue.

  3. If you keep seeing this in your Xcode console, [Fabric] failed to download settings Error Domain=FABNetworkError Code=-5... blah blah blah, then go clean that Build Folder first (shift + cmd + k).

If your next build works, try force crashing your app and check out the crash logs on Firebase.

Here's my stack: Xcode 10.2.1 | Fabric 1.9 | Crashlytics 3.12

MkVal
  • 1,044
  • 1
  • 11
  • 17
3

The issue for me was I was using the old Fabric before and I had to remove the key from my info.plist

MobileMon
  • 8,341
  • 5
  • 56
  • 75
2

I followed the https://fabric.io/kits/ios/crashlytics/install documentation and added the Run Script and updated Info.plist but still got the above issue.

Apparently, I had accidentally added twice 'New Run Script Phase'. After removing the unnecessary 'Run Script's the project compiled successfully.

Xcode 10.1 Fabric 1.7.5 Crashlytics 3.10.4

Alex Pavtoulov
  • 830
  • 1
  • 6
  • 9
2

Documentation

  • if crashlytics is already set up in your project (in case of migration),

    1. Remove the fabric key from Info.plist (need to remove the dictionary and the key for Fabric)
    2. Follow the documentation.(just need to use "${PODS_ROOT}/Fabric/run", instead of "${PODS_ROOT}/Fabric/run" key1 key2 in the Run script under build phase)
  • if crashlytics is not setup in your project already(starting a fresh integration with firebase crashlytics), simply follow the documentation.

cnu
  • 443
  • 4
  • 9
0

If you're using Crashlytics, you might have to go into your Build Phases -> Crashlytics configuration and add it into the shell/bin/sh section like this: `set -e

if [[ ${PODS_ROOT} ]]; then echo "info: Exec Fabric Run from Pods" "${PODS_ROOT}/Fabric/run" YOUR KEY HERE else echo "info: Exec Fabric Run from framework" "${PROJECT_DIR}/Fabric.framework/run" YOUR KEY HERE fi`

0

Alternative script

  1. Go to "Build Phases"
  2. Create a new script in + -> "NewRun Script Phase"
  3. Chech that it's always the last one
  4. Copy and Past this script
set -e

echo "info: Exec Upload dSYM"
#Path for google service .plist 
GOOGLE_SERVICE_INFO_PLIST="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/GoogleService-Info.plist"
#Path for DSYM directory
DSYM_PATH="$DWARF_DSYM_FOLDER_PATH/dddd/$DWARF_DSYM_FILE_NAME"
#Firebase command script
CMD=""
if [[ ${PODS_ROOT} ]]; then
  echo "info: Exec FirebaseCrashlytics Run from Pods"
  CMD="$PODS_ROOT/FirebaseCrashlytics/upload-symbols"
else
  echo "info: Exec FirebaseCrashlytics Run from framework"
  CMD="$PROJECT_DIR/FirebaseCrashlytics.framework/upload-symbols"
fi

echo "info: Checking if .plist exists"
if [ -f "$GOOGLE_SERVICE_INFO_PLIST" ]; then
    echo "info: $GOOGLE_SERVICE_INFO_PLIST exists."
else 
    echo "ERROR: $GOOGLE_SERVICE_INFO_PLIST does not exist."
    exit 1
fi

echo "info: Checking if .dSYM"
if [ -d "$DSYM_PATH" ]; then
    echo "info: $DSYM_PATH exists."
else 
    echo "ERROR: $DSYM_PATH does not exist."
    echo "info: try fallback"
    DSYM_PATH=` find "${DWARF_DSYM_FOLDER_PATH}" -name "*.dSYM" | xargs `
    if [ -d "$DSYM_PATH" ]; then
        echo "info: $DSYM_PATH exists."
    else 
        echo "ERROR: $DSYM_PATH does not exist."
        exit 1
    fi
fi
echo "info: Check if upload-symbols script exists"
if [ -f "$CMD" ]; then
    echo "$CMD exists."
else 
    echo "ERROR: $CMD does not exist."
    exit 1
fi

echo "info: Starting command upload-symbols"
"${CMD}" -gsp "$GOOGLE_SERVICE_INFO_PLIST" -p ios "$DSYM_PATH" > /dev/null 2>&1 &
echo "info: Symbol uploading will proceed in the background."
echo "info: remove '> /dev/null 2>&1 &' to test in the main thread and see if there are any errors, or open console and filter with 'upload-symbols'"

Scinfu
  • 1,081
  • 13
  • 18