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

What are the core tools for debugging iOS apps?

Recorded – watch the full episode on YouTube.

Apart from just using po and breakpoints, what other debugging tools do you rely on heavily?

Carola Nitz: I mean the UIView debugging tool is for me really, really important especially when you have layout issues. You get to see so much more about what is wrong. You can focus in on the constraints for example. And then you notice like, "Oh, this is an ambiguous constraint and I didn't even notice that when I laid out my code." So for me doing a lot of UI work, that is definitely a very important tool.

Paul Hudson: Right, because that's where you can pull apart your UI in 3D, you can spin it around, you can filter by depth and layers and you can dig and say, “What do you have for constraints?” Or, “why are you opaque?” And it really gives you an idea of what's actually happening with your finished code.

"I don't think a lot of people realize you get the addresses in the view debugger for a certain view. If you take that, if you cast that address to whatever object it is let's say UIView, you can actually on the fly change properties."

Carola Nitz: Not only that, actually I don't think a lot of people realize you get the addresses in the view debugger for a certain view. If you take that, if you cast that address to whatever object it is let's say UIView, you can actually change properties on the fly. So sometimes what I do is change the background color of something just to make sure it’s actually visible, and once you hit resume again it changes the background color and you can manipulate code that way.

Paul Hudson: So there you go. It sounds like an immediate win: if you're doing po already to print things out, use the view debugger, find the address for the view you want, and then po that – and actually then modify it and see it change live.

Now as a related question to that, this is a random one but I'm curious: when you're thinking to yourself is this view visible you give it background color, we all give our background color which background color do you choose?

Carola Nitz: I use red. I really use red.

Paul Hudson: Yes, I use red as well – good!

Carola Nitz: Why are people using like blue, purple or green?

Paul Hudson: Those weird people over there are definitely using different colors than red. But yeah, I think it is mostly red.

Carola Nitz: I don't know why, it's just so easy.

Paul Hudson: It just stands out as a big warning sign this view is what is it doing over there? It shouldn't be over there it should be over here or bigger or behind something else. And yeah, red just screams problems to me I guess.

Carola Nitz: Yeah, same.

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

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.