Swift Components Tour – Breakpoints Step In and Out

In this lesson

Back in the Swift Components Tour app, let’s talk about how to use your breakpoints like a boss using Step In and Step Out actions.

Kyle Roberts
Swift Guru at Large

Kyle's Series


Tap on time to skip ahead


Hello world, Kyle here with Brax.tv and we’re going to talk about the step in and step out buttons in this debug area when we are working with breakpoints.


Normally, when we would hit a breakpoint and I do have one breakpoint up here in viewDidLoad of the NIOTextFieldViewController. Then when we open the NIOTextFieldViewController by hitting that row in the navigation table here, then we’re going to hit this breakpoint. We’ve stopped the current execution of the program and we are waiting for us to continue, step over, step in or step out. Normally, if we continue, we’ll just pass the breakpoint like nothing happened. We got a glimpse of what was going on in the current scope, now the view controller’s open.


What happens if we hit that same breakpoint again and step over? We know we’re just going to pass the execution of this one line and we will continue to the next line of code. Maybe if anything changed we could be monitoring it down here. Neither of these lines here are going to change anything so we can just step over again, nothing will change and we’re at the end of the method. All we have left to do is continue program execution.


Now, let’s look at the step in and out buttons, those are new. Here we are with our breakpoint, right before the call of self.startAnimatingLabel(). What if we wanted to see what was happening in that method without actually having to put another breakpoint down here, like this? Well, you can do that with the step in button. Right before the execution of this method, we’re going to step in. Instead of up here and stepping over that method, we’re actually going to go into the execution of that method if we do have access to it. Sometimes when you call a method that’s part of a private API and when you try to step in you will not be able to see the code and what’s happening there. But since we do have access to this startAnimatingLabel method, we have moved the current execution point to the first line in that method. Now, we can continue program execution or we can step over, as usually. I stepped over, we’re onto the next line. Step over one more time, we’re at the end of the method. Let’s continue program execution.


How do we use the step out button? Well, before we can step out we have to step in, so we’re back at the original breakpoint. We’re going to step in. Our execution point is at the first line of the startAnimatingLabel method. Maybe at this point in time, we don’t care what’s going to happen in these two lines, we just wanted to pop into this method to see what was going on. But we don’t really care about anything else other than we did hit this method. So we can step out of and that will continue the execution past the scope of this method and back to where we were.


Though where we were was on this line, we have actually run the execution of this startAnimatingLabel method so that the execution point is now on the line below that. Let’s just continue execution and get back to where we were: in the Swift Components Tour – the best place ever. Thanks for watching.

Additional Info

Register to get access to additional resources and info.