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
- 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
applicationDidFinishLaunchingmethod. A good place could be a button action.
- 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!
- 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;
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.