Firebase/Crashlytics Version 4.0.0-beta.1 - ForceCrash?

2k Views Asked by At

How do you force a crash on the new version of Firebase Crashlytics 4.0.0-beta.1?

I have tried to crash the app with fatalError(), but the Crashlytics doesn't record the crash in Dashboard.

Also tried to unplug my device, run the app and force crash with fatalError() but still no report in Dashboard.

Also tried Crashlytics.sharedInstance().crash(), but getting error message Type 'Crashlytics' has no member 'sharedInstance()'.

Any ideas? Thank you

6

There are 6 best solutions below

4
Keshu R. On BEST ANSWER

As the documentation says, use

Crashlytics.sharedInstance().crash()

Crash reports are sent to the server when you start the app again.

Option2: If nothing works, just declare an optional and force unwrap it. :) CRASH

var v : Int!

// then in your viewDidLoad() or in button action
let a = v!
0
Vasucd On

Use pod version in your file pod 'Crashlytics', '~> 3.14.0' .

This code is working in my case.

Crashlytics.sharedInstance().crash()
0
Jun Josky On

You can use fatalError() instead of Crashlytics.sharedInstance().crash()

5
Ucdemir On

For new SDK

import FirebaseCrashlytics


fatalError()
1
elderio On

Take a look into your Info.plist, rename the following key and set it TRUE

firebase_crashlytics_collection_enabled -> FirebaseCrashlyticsCollectionEnabled

Or you can also try this

Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
0
Michał Ziobro On

Firebase (Google) recommends to use just

// Force a test crash
fatalError()

Old API was deprecated and there is no more crash() method or throwException()

Check this https://firebase.google.com/docs/crashlytics/upgrade-sdk