Debug breakpoint in Swift Playground?

Matt, I could not enter code in the comments so here is a better view of using a variable on a line by itself to "debug" it.

for index in 1...5  {
    dosomething(foo);
    foo;
}

Then you can click the eyeball on the right hand side to see a history of foo as it was modified in the loop.


There's no debugger so you can't add any breakpoints.


If you want to pause execution of a playground to have a peek at what's going on, you can use sleep. The information you can get isn't nearly as granular as what you can get from lldb.

To do this, you'll need to add import Foundation at the top of your playground.

Then, wherever you want to pause execution, you can add this:

sleep(10) // 10 second pause...you can make the number whatever you want