Is there a quick way to force a crash?

This page is now deprecated. For the latest version, please click here.

Forcing a crash is a great way to test out the SDK, but it's a bit trickier than you might think. 

How to force a crash

We've built a convenient API you can use to cause a crash:

[[Crashlytics sharedInstance] crash];

  1. First, make sure you place your test crashing code in a different place than applicationDidFinishLaunching. This is only for testing -- Crashlytics will detect crashes in your applicationDidFinishLaunching method. A good place could be a button action.
  2. Next, compile, build, and run your app with Xcode's debugger disconnected! Don't know how to disconnect it? That's ok - just go here!
  3. Now, that Xcode's debugger is disconnected, force the crash by pressing the button you attached the crash code to and then relaunch the app.


If you'd like to see other kinds of crashes, you can experiment:

int *x = NULL; *x = 42;

Like raising exceptions? Well, you can have fun too :-) 

Some common ways to do that are:

[NSObject doesNotRecognizeSelector];

[arrayWithOnlyTwoElements objectAtIndex:3];

Keep in mind that exceptions are not guaranteed to a crash.  (The full code path, including code in system libraries matters here.)

Fun fact  (feel free to share at your next party)

Divide-by-zero is illegal on i386 and x84-64, but is a valid operation on ARM!  Dividing by zero will cause crashes in the simulator, but not on iOS devices.

Feedback and Knowledge Base