You should definitely not compile -Ounchecked for release to use precondition only during testing. The -Ounchecked compilation also disables checks for things like an off-bound array and nil unwrapping, which can lead to quite unpleasant production errors related to memory corruption.
You can control the behavior of the statement regardless of the compiler optimization options with the -assert-config argument to swiftc :
$ cat assert.swift assert(false, "assertion asserted") println("made it here...") $ swiftc -Onone assert.swift; ./assert assertion failed: assertion asserted: file assert.swift, line 1 Illegal instruction: 4 $ swiftc -O assert.swift; ./assert made it here... $ swiftc -O -assert-config Debug assert.swift; ./assert assertion failed: assertion asserted: file assert.swift, line 1 Illegal instruction: 4 $
It doesn't seem like Xcode Build Settings are configured for this, but you can add it using the Other Quick Flags option.
source share