How do I force a crash in Swift iOS app with Fabric SDK?

Michael picture Michael · Jan 20, 2015 · Viewed 11.2k times · Source

All I can find is Is there a quick way to force a crash? which says to:

[[Crashlytics sharedInstance] crash];

which I think in Swift would be

Crashlytics.sharedInstance.crash()

but this does not seem to exist. (perhaps the docs are out of date and no longer apply since Fabric gobbled up Crashlytics?)

I see that there is a Crashlytics.crash(self:Crashlytics) ...nevermind, friggin XCode's completion is always broken for me. See answer below.

Answer

FFFF0H picture FFFF0H · Mar 27, 2020

If you are using the new Firebase Crashlytics SDK note that import Crashlytics has been replaced by import FirebaseCrashlytics. The crash() method is no longer available in the new SDK. As recommended by Firebase, simply use:

Swift:

fatalError()

Obj C:

assert(NO);