iosswiftcrashlyticstwitter-fabric

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


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.


Solution

  • 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);