Your problem lies here:
Int(arc4random())
arc4random() returns a UInt32—an unsigned 32-bit integer. If you compile the above code for a 32-bit platform, like an iPhone 4, say, then the Swift Int you're trying to stuff it into will be a 32-bit signed integer, an Int32. (This is also the reason @Pavi can't reproduce the problem in a playground; the playground will be 64-bit.)
So, on a 32-bit platform, sometimes—about half the time, in fact—arc4random() will be returning a value that's too large for your Int constructor, and you'll get an assertion failure in the library (EXC_BAD_INSTRUCTION is the normal clue to this; assertion failures deliberately throw a bad instruction onto the processor to halt everything.)
You're basically deciding whether to crash based on the toss of a coin :)
So, you either need to use a specific, large enough integer type for your ID (UInt32 should always work, as that's the return type of arc4_random), or limit the results of the random number generator, for example by using arc4random_uniform to generate numbers within a specific range.
In fact, you could probably fix things by removing the unnecessary cast to an integer anyway:
setObjectId("(arc4random())")
...but of course it'll depend on what you're actually trying to do, and why...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…