What's a reliable way to make an iOS app crash?

I want to test my app's crash reporting out in the field by deliberately having it crash when the user performs a particular action that a real user is unlikely to do accidentally.

But what's a good reliable way of making the app crash that doesn't create a warning at compile time?

Edit: Note that many seemingly obvious answers to this question result in exceptions that get caught by Cocoa and thus don't result in the app crashing.


Solution 1:

in Objective-C use C directly to cause a bad access

strcpy(0, "bla");

Note: while this works on any system I know -- in a future version of the C runtime OR the compiler this might not lead to a crash anymore. see Is null pointer dereference undefined behavior in Objective-C?)

(in swift you would have to bridge to objC to do this)

Solution 2:

My current favourite:

assert(! "crashing on purpose to test <insert your reason here>");

A classic:

kill( getpid(), SIGABRT );

And some pr0n:

*(long*)0 = 0xB16B00B5;

All of them generate crashes captured by my crash reporting tool.