Report Crashes

Firebase Crash Reporting creates detailed reports of the errors in your app. Errors are grouped into clusters of similar stack traces, and triaged by the severity of impact on your users. In addition to 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:

  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:

    Objective-C

    @import Firebase;
    

    Swift

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

    Objective-C

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

    Swift

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

Upload symbol files

In order to view human friendly crash reports, you need to upload symbol files after each build. This can be done automatically by adding a run script to Xcode.

  1. Download a service account key to authenticate your uploads:
    1. Go to the Firebase console and open your Firebase project.
    2. Click settings and select Permissions.
    3. On the Permissions page, select Service Accounts from the left menu.
    4. Click Create service account.
    5. Name the service account "Symbol Upload service account".
    6. Set the Role to Editor (Project -> Editor)
    7. Check the box for Furnish a new private key.
    8. Select the JSON option for key type.
    9. Click Create. This automatically downloads a JSON file with the required keys.
  2. Add an upload script for your symbol files:
    1. In Xcode, click on your application target, select Build Phases, and click `+` to add a phase.
    2. 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

  1. Add an assert to your AppDelegate's didFinishLaunchingWithOptions method to cause a crash when the app launches, right after the Firebase initialization call:

Objective-C

assert(false);

Swift

fatalError()

  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 secs 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:

Objective-C

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

Swift

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

Known issues

Device models may not be showing in error reports. This will be addressed in an upcoming Pod update.

Send feedback about...

Need help? Visit our support page.