Best practice to trace/debug when using Xcode?

Hi,

I'd like to know which best practices exist to trace/debug when using Xcode?

For example, let's assume I have a struct Foobar where I write some code in the init(), how can I see the computed values?

So far I'm running the struct code in a test suit, but I need to run command+u all the time. When I used the playground, it was nice because I can see the computed value on the side panel. I wonder what other options exist there?

This is better asked on the Apple Developer Xcode forum, or other Xcode support web sites, but, you need to look into debugger breakpoints. Setting a breakpoint in your init function pauses the program, and hands control back to the debugger. In Xcode, the state of the program at that time can be queried, other things can be shown/done.

Ok thanks @jonprescott

So, without xcode you'd run it through the CLI? Have a watcher and run the command or something? What's the common process? Let's say to simply print(x)

Not sure why you are asking about using Xcode if you are not going to use Xcode, but, if you want to use the CLI, you use the lldb debugger. This is the same debugger that Xcode uses behind the scenes. man lldb is your friend.

Or, you can do it the old-fashioned way, and just put print statements in your code to print out the state.

What do you mean by a test suite? Are you in Xcode and running tests, or something different?

Yes, the test suite are some tests I have. The goal is just to look into what other people do, to speed up development time and my comprehension of swift and the available tools. At the moment I've copied what I need, into a playground in Xcode. I'll ask in the Xcode forum to understand how they work.

Appreciate your time, thank you @jonprescott