setup crashlytics in swift

To integrate Crashlytics in your Swift app, follow these steps:

  1. Install Firebase Crashlytics in your Xcode project by adding the following to your Podfile:
main.swift
pod 'Firebase/Crashlytics'
27 chars
2 lines
  1. Install the pod by running:
main.swift
pod install
12 chars
2 lines
  1. Open AppDelegate.swift and add the following at the top of the code:
main.swift
import Firebase
import FirebaseCrashlytics
43 chars
3 lines
  1. Initialize Firebase in the didFinishLaunchingWithOptions method:
main.swift
FirebaseApp.configure()
24 chars
2 lines
  1. Enable Crashlytics:
main.swift
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
64 chars
2 lines
  1. Finally, trigger a test crash to verify that everything is working:
main.swift
Crashlytics.crashlytics().log("Test Crash")
fatalError()
57 chars
3 lines

Make sure to remove the test crash before releasing the app.

That's it! You can now see crash reports for your app in the Firebase console.

gistlibby LogSnag