Add Crashlytics to your WatchOS app

Add Crashlytics to your WatchOS app


I've been working on a WatchKit extension for an existing iOS application recently and I went through a problem: Firebase Crashlytics integration on WatchOS. Since it was quite difficult for me to find clear documentation about this on the internet I thought it would be interesting to share a step-by-step guide on how I did it for my project.

This guide assumes you already have configured your product in Firebase Console. If it's not the case, you can follow the guide at this URL. Also, make sure you have the GoogleService-Info.plist copied at the root of your WatchExtension folder.


1. Adding the dependency

You'll need to add the dependency to your Podfile as you would on a normal iOS application; make sure to add it under the WatchKit extension target.


target 'ExampleApp Watch Extension' do
    platform :watchos, '5.1'
    # other dependencies
    pod 'Firebase/Crashlytics', '7.10.0'

Then you'll need to run the two commands below to update your dependencies and launch your app in XCode.

$ pod install
$ open example-app.xcworkspace

2. Adding Firebase Crashlytics SDK to your app

  • In your ExtensionDelegate.swift file, import the Firebase module:
import Firebase
func applicationDidFinishLaunching() {
    // Firebase configuration
  • Compile your app again.

3. Crashlytics initialization

You'll need to initialize crashlytics by adding a Build Phase to your project so XCode will automatically download your project's DSYM file each time your application will crash so that Crashlytics will be able to automatically generate crash reports.

  • Step 1: Open XCode and select the project in the left navigation.

  • Step 2: Click on the WatchKit Extension target and go to the Build Phases tab.

  • Step 3: Click the plus button on the top left side, then choose the "New Run Script Phase" option

  • Step 4: Add this code


You should then have something like this :

SC 1

make sure that your new generation phase is the last generation phase of the project, otherwise, Crashlytics cannot initialize correctly.

  • Step 5: Take some beer, you've just accomplished something great!

4. Test your integration

Now we have configured Crashlytics in our project, we need to make sure it works. To do this, we will create a test crash and see how it's handled by Crashlytics and shown in our console.

Go to your project settings, choose the Watch target (i said Watch, not Watch Extension); then go the the Build settings tab and type debug information format in the search bar. the value is probably 'DWARF', change it to DWARF with dSYM File.

Why this you'll ask me (yeah, I can read your mind ;) ) You need to disconnect your simulator from your XCode debugger to be able to see crash reports in the crashlytics console. (don't ask me why, I am not employed at Google, even if I dream of it).

Go to your app (for example the ExtensionDelegate.swift) file and add the code below after Firebase configuration:

func applicationDidFinishLaunching() {
    // Firebase configuration
    Crashlytics.crashlytics().record(error: NSError(domain: "Test crash", code: 00, userInfo: nil))

When you are done, launch your app and you normally should be able to see your first report in your Crashlytics console.

Thanks for reading.

Did you find this article valuable?

Support Steve Nosse by becoming a sponsor. Any amount is appreciated!