# Crashlytics

Firebase Crashlytics is a real time crash reporting tool that helps us pinpoint crashes from our users. It makes is very easy to receive detailed insight on the events that led up to the crash, allowing us to quickly reproduce bugs and determine the root cause.

### Getting Started

In order to set up Crashlytics, we must have a Firebase project configured for our app.

1. Under **Project Settings > General**, download the `GoogleService-Info.plist` file and drag it into our project directory.
2. Install the Firebase SDK via CocoaPods or Swift Package Manager and choose the libraries that we want to use (in this case **FirebaseCrashlytics**).
3. Follow the instructions from the [Firebase website](https://firebase.google.com/docs/ios/setup) to add the initialization code.

### Adding the SDK

The [official Firebase documentation](https://firebase.google.com/docs/crashlytics/get-started?platform=ios#add-sdk) does a pretty good job explaining how to set up Crashlytics so I won’t repeat it here. Follow the guide to add the SDK.

Note: If we are using CocoaPods as the package manager for our project, then there are 2 differences:

1. Firstly, skip Step 1 (adding Firebase through github and Swift Package Manager). The only thing we want to do from that step is check that **Other Linker Flags** does have `-ObjC`.
2. Secondly, when adding a new script to Build Phases, we need to make sure to use the script `${PODS_ROOT}/FirebaseCrashlytics/run` instead of the provided script (which will search for a Swift Package Manager file that doesn’t exist)!

### Viewing Crashes

If we followed the documentation correctly, our app’s dSYM’s files should automatically be uploaded to Crashlytics, allowing us to read and process crashes.

<figure><img src="https://1509678725-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lwk7443W4ukbAF9S07e%2Fuploads%2FgW3W851KmmiBdzwGgMSO%2FUntitled.png?alt=media&#x26;token=d9b58d9a-3ca4-4e98-999c-7f755346b4b0" alt=""><figcaption><p>View the stack trace leading up to the crash in Crashlytics.</p></figcaption></figure>
