This quickstart describes how to set up Firebase Crashlytics in your app for the first time using the Firebase Crashlytics SDK so you can get comprehensive crash reports in the Firebase console. Note that the SDK is currently in beta, so if you prefer to use a more stable version, you can set up Crashlytics using the legacy Fabric SDK instead.
Before you begin
Skip this step if your app already uses Firebase: First, add Firebase to your iOS project. Make sure to register your app and add a Firebase configuration file (you don't need to add any Firebase SDKs yet). If you don't have an iOS app, you can download a sample app.
Step 1: Set up Crashlytics in the Firebase console
Click Crashlytics in the left-hand nav panel of the Firebase console.
If your Firebase project has multiple apps registered in it, select the app you just added from the dropdown next to Crashlytics in the top bar of the console.
Click Set up Crashlytics.
Select This app is new to Crashlytics (it doesn't have any version of the SDK).
Step 2: Add Firebase Crashlytics to your app
Open the podfile you created for your Firebase project and add the
FirebaseCrashlyticspod. For an optimal experience with Firebase Crashlytics, we recommend enabling Google Analytics in your project by adding the Firebase pod for Analytics to your app as well.
pod 'Firebase/Crashlytics' # Recommended: Add the Firebase pod for Google Analytics pod 'Firebase/Analytics'
Install the pods, then re-open your .xcworkspace file to see the project in Xcode:
Import the Firebase module in your
FirebaseAppshared instance, typically in your app's
// Use the Firebase library to configure APIs. FirebaseApp.configure()
// Use the Firebase library to configure APIs. [FIRApp configure];
Recompile your app.
Step 3: Initialize Crashlytics
You can initialize Crashlytics by adding a run script to your project’s build phase. The run script allows Xcode to automatically upload your project’s dSYM file whenever your app crashes so that Crashlytics can automatically generate crash reports.
Open your project in Xcode, then select its project file in the left navigator.
From the Select a project or target dropdown, select your main build target.
Select the Build Phases tab, then click> New Run Script Phase.
Expand the new Run Script section that appears. In the script field (located under the Shell field), add a new run script:
Xcode versions 10 or higher only: Add your app’s dSYM location as an input file that enables Crashlytics to automatically generate dSYMs for large apps more quickly. For example:
You can also provide your app's built
Info.plistlocation to the build phase's Input Files field:
After you add the SDK to your app, Crashlytics automatically gets to work listening for and collecting crash reports.
Step 4: Run your project
Finally, run your app. Your device logs display the Firebase verification that initialization is complete.