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

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)


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.


Since we all use Clang for iOS, this is fairly reliable:

__builtin_trap();

This has the benefit that it's designed for exactly this purpose, so it shouldn't generate any compiler warnings or errors.