UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Which parts of Instruments are useful for debugging?

Recorded – watch the full episode on YouTube.

Do you recommend one particular tool you use most of the time in Instruments, or you just try them all out and see which one works best for you?

Carola Nitz: I mean honestly I really don't use it that often. It's really just when I have like a memory issue and I need to see what kind of method is allocating the most. WWDC videos have been the best for me so far – Instruments 101, and going back even to older videos to get an overview of what tools are out there.

"I use po to manipulate objects on the fly. It helped me so much where you just cast an address and then set the background color, set a frame. You can do it on the fly while your program is running."

Paul Hudson: I think if I could recommend to folks if you could do one change to improve your debugging workflow I would say to use conditional breakpoints more – that's my personal favorite thing. Because you can add breakpoints throughout your network stack for example, throughout your buying stack, throughout your authentication stack, or whatever it is you’re working on. and then just disable them all with the condition “is network debugging true? Is authentication debugging true?” All as an enum elsewhere in your code and just leave them there forever. Leave the whole stack of breakpoints in there forever and ever and ever, all disabled, all doing nothing. Until you enable an enum then bang – now you're debugging networking, bang now you're debugging authentication. That's my personal number one fix for better debugging. If you want to recommend to somebody your number one best piece of advice to improve debugging, what would it be?

Carola Nitz: For me, it's really that I use po to manipulate objects on the fly. It helped me so much where you just cast an address and then set the background color, set a frame. You can do it on the fly while your program is running.

Paul Hudson: Manuel Carrasco Molina adds, "Start using gauges and deep dive in Instruments. And that's actually quite important because gauges are really nice in Xcode and you can totally ignore them by accident. They tell you the CPU load, the RAM load, and more right there in this basic summary. And if you need to go into it further, then fine – use Instruments. But for so many things these days you haven't got to go into Instruments, you can just stick in Xcode and use Xcode’s tools, which is really, really nice I think.

Carola Nitz: It's also the first thing I notice when I have a loop. In memory if something gets allocated a heck of a lot because I have a layout loop or something, the gauges are going up. And that's the first time that I see, "Okay, there's something going wrong."

This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.

Listen on Apple Podcasts

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.