JacobJ JacobJ - 4 years ago 227
Swift Question

Can I cause Xcode's debugger to break programmatically?

I'm looking for a way to cause the XCode debugger to break programmatically from Swift code if my iOS program is running in the debugger. This would be similar to the way System.Diagnostics.Debugger.Break() works in the Visual Studio environment. Is this possible? The point would be for any developer that hits a particular section of code to break, but not to have a fatal error that causes code execution to stop permanently.

Edit: This is a little different than the user asking to "enable" a breakpoint (though the answer provided in that question is really what I was looking for). I'm also still looking for something that can be done in Swift without interop, bridging headers, and such.

Answer Source

Putting asm("svc 0") in your code will stop your running application if debugging through xcode. See: http://stackoverflow.com/a/34078247/215400

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download