iOS migrating from Crashlytics to FirebaseCrashlytics

Viewed 545

I have previously migrated my project from Fabric to Firebase, and am now trying to migrate from Crashlytics to FirebaseCrashlytics, but I'm running into issues. I have followed along with the upgrade guide but to no avail.

My project has multiple schemes, 4 to be exact, and each one has a different Bundle ID and therefore, also a different GoogleService-Info.plist. I've addressed this issue in my Crashlytics run script phase and it looks as follows:

GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist

GOOGLESERVICE_INFO_APP_STORE=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/AppStore/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PRODUCTION=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/Production/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_BETA=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/Beta/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_STAGING=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/Staging/${GOOGLESERVICE_INFO_PLIST}

${PODS_ROOT}/FirebaseCrashlytics/run

if [ "${CONFIGURATION}" == "AppStore" ]
then
    echo "Setting up Crashlytics for App Store..."
    "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_APP_STORE}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
elif [ "$CONFIGURATION" == "Production" ]
then
    echo "Setting up Crashlytics for production..."
    "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_PRODUCTION}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
elif [ "$CONFIGURATION" == "Beta" ]
then
    echo "Setting up Crashlytics for beta..."
    "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_BETA}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
elif [ "$CONFIGURATION" == "Staging" ]
then
    echo "Setting up Crashlytics for staging..."
    "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_STAGING}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
else
    echo "Can't find matching GoogleService-Info.plist for Crashlytics configuration..."
fi

Then my App Delegate looks like this

@import Firebase;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [FIRApp configure];

    // Just put these in for testing

    [[FIRCrashlytics crashlytics] setCrashlyticsCollectionEnabled:NO];
    [[FIRCrashlytics crashlytics] checkForUnsentReportsWithCompletion:^(BOOL hasUnsentReports) {
        if (hasUnsentReports) {
            NSLog(@"-=-=-=-=- HAS UNSENT REPORTS -=-=-=-=-");
        } else {
            NSLog(@"-=-=-=-=- NO UNSENT REPORTS -=-=-=-=-");
        }
    }];

    if ([[FIRCrashlytics crashlytics] didCrashDuringPreviousExecution]) {
        NSLog(@"-=-=-=-=- APP CRASHED DURING LAST RUN -=-=-=-=-");
    }
    return YES;
}

To test it out. I launch it from Xcode, then stop it so it detaches the debugger. Then I launch it from the simulator and press a button that calls assert(NO); and it crashes as expected. Then I launch it from Xcode again, and I always just see the line in the debugger:

-=-=-=-=- NO UNSENT REPORTS -=-=-=-=-

I can't figure out what's going wrong. At first I thought it wasn't sending the crashes to Firebase, but now I don't think it's even registering that there are crashes is I keep seeing that there are no unsent reports.

Any help appreciated.

1 Answers

Well, unfortunately, although the official docs say to use assert(NO); to test your integration, I found that using this method to crash the app did not actually generate a crash report for me.

I used a different method to crash the app and it ended up working.

For example, NSLog([FIRCrashlytics crashlytics]); worked for me, but I'd expect anything else really (besides the assert they have in their docs).

Related