Report Crashes on iOS

Firebase Crash Reporting creates detailed reports of the errors in your app. Errors are grouped into issues based on having similar stack traces, and triaged by the severity of impact on your users. In addition to receiving automatic reports, you can log custom events to help capture the steps leading up to a crash.

Set up Crash Reporting

To set up Crash Reporting in your app, do the following:

  1. Install the Firebase SDK.
  2. In the Firebase console, add your app to your Firebase project.
  3. Add the dependency for Firebase Crash Reporting to your Podfile:
    pod 'Firebase/Crash'
  4. Import the Firebase module in your UIApplicationDelegate subclass:

    Swift

    import Firebase
    

    Objective-C

    @import Firebase;
    
  5. Configure a FIRApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:

    Swift

    // Use Firebase library to configure APIs
    FirebaseApp.configure()
    

    Objective-C

    // Use Firebase library to configure APIs
    [FIRApp configure];
    

Upload symbol files

In order to view human-readable crash reports, you need to upload symbol files after each build. This can be done automatically by following these steps to add a run script to Xcode:

  1. Download a service account key to authenticate your uploads. From the Firebase console, select your project, and then click Generate New Private Key.
  2. In Xcode, click on your application target, select Build Phases, and click `+` to add a phase.
  3. Select Run Script and add the following content, setting appropriate values for your service account path and GOOGLE_APP_ID:
    # Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
    GOOGLE_APP_ID=1:my:app:id
    
    # Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
    "${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"
        

Create your first error

To create your first error, add an assert to your AppDelegate's didFinishLaunchingWithOptions method to cause a crash when the app launches, right after the Firebase initialization call:

Swift

fatalError()

Objective-C

assert(false);

Now that you have added this assert, you can do the following to create an error:

  1. Launch the app from Xcode.
  2. Click Stop in Xcode to detach from the debugger.
  3. Launch the app directly from the home screen on the device or emulator.
  4. Wait until your app crashes.
  5. Remove the crashing line so your app can start successfully.
  6. Launch the quickstart from Xcode again. Within 15 seconds, you should see a log message indicating that the report was successfully uploaded.
  7. Check the Crash Reporting section of the Firebase console to see the error. Note that it takes 1-2 minutes for errors to show there.

Create custom logs

You can use FIRCrashLog() to create custom log messages that are included in your crash reports. The following example demonstrates creating a log message:

Swift

FirebaseCrashMessage("Cause Crash button clicked")
fatalError()

Objective-C

FIRCrashLog(@"Cause Crash button clicked");
assert(NO);

Bitcode support

If you have bitcode enabled, you need to do the following to symbolicate your app so that you can read the stack traces collected by Crash Reporting:

  1. Download your app's debug symbols (.dSYM) files. To learn how to download these files, see Viewing and Importing Crashes in the Devices Window.

  2. After all .dSYM files have downloaded as an .xcarchive, extract the .dSYM files to a convenient location.

  3. Using the batch-upload script, upload the .dSYM file for the app version that you need to symbolicate. It may take a minute for Spotlight to update its index to include this file.

    ./Pods/FirebaseCrash/batch-upload -i "Path/To/Info.plist" -p "Path/To/GoogleService-Info.plist" "Path/To/ServiceAccount.json" "UUID-OF-DSYM"
      

Known issues

  • The Firebase SDK does not currently support using the NSException class in the Xcode simulator. If you use this class, it results in malformed stack traces in the Firebase console. As a workaround, either use a physical device or test with a different type of exception such as an assert.

  • Crash Reporting uses a unique ID to identify each user. Due to a known bug in Xcode 8.1, creating this ID fails on iOS 10 simulators, preventing the upload of error reports. To work around this in Xcode 8.1, you can run tests on a device, or turn on Keychain Sharing in the Capabilities section of your app settings. This bug has been addressed in the beta release of Xcode 8.2.

Next Steps

To learn about configuring email alerts when new issues or regressions are reported, see Configure Email Alerts.

Send feedback about...

Need help? Visit our support page.