How to add and use a breakpoint in XCode

Oscar de la Hera Gomez
Two flowers that represent Swift and XCode side by side. Beneath them sits the text “Add and Use a Breakpoint”.

A step by step guide on adding, stopping and analyzing an iOS, MacOS, TVOS or WatchOS app at a breakpoint using XCode.

Step One: Add the Breakpoint

A screenshot of Xcode showing the AppDelegate.swift file. We have highlighted that if you click a line number a visual will appear demonstrating that you have added a breakpoint.

Open the relevant file and click the line number that you wish to add a breakpoint to.

After clicking, a visual should appear on the line similar to that above, which indicates that you have an active breakpoint in that file at that line.

Step Two: Run

A screenshot of XCode showing that we have set a breakpoint on line 14 of the AppDelegate.swift file. We have highlighted the play button that appears on the top left of XCode. Click this button to run the app on a device. As we have set the breakpoint on line 14, the app will stop at the Splash screen, allowing you to analyze it.

Press the Play button on the top left of Xcode, or press Command + R on your keyboard.

Step Three: Analyze

A screenshot of Xcode showing the AppDelegate.swift file. The screenshot demonstrates how Xcode changes to show that that the app has been stopped at the breakpoint. The Variable Viewer is now present and all the items on the Debug Bar are now active.

Perform the necessary actions to trigger the breakpoint.

When the code crosses this line, XCode will stop and give you insight into how the app is operating at that breakpoint.

At this point you can carry out multiple actions, including:

A | Inspect Variables

Xcode paused on a breakpoint in an app, showing the debug navigator, source code editor with breakpoint highlighted, variable viewer, and debugger console.

Inspect relevant app variables using the variable viewer that appears on the bottom left.

B | Continue, Step Over, Step Into, Step Out, Debug View Hierarchy, Debug Memory Graph, Apply Environment Overrides or Simulate Location

Xcode debugger toolbar, showing the show or hide debug area button, activate or deactivate all breakpoints button, continue button, step into button, step out button, debug view hierarchy button, debug memory graph button, environment overrides button, simulate location button, and choose stack frame area.

Using the Debug Bar above the variable viewer on the bottom left, carry out breakpoint specific actions that include:

  • Continue Program Execution (Play Button) - This makes the app continue and essentially means that you don't want to continue analyzing the app at the breakpoint.
  • Step Over (Triangular Arrow) - Run the next line of code in the same function. If the next line is the last, it will perform the equivalent of Continue Program Execution.
  • Step Into (Down Arrow) - Run the next line of code. If the next instruction is inside another method or function, the debugger jumps to that function and continues executing it each time you click the Step Into button.
  • Step Out (Up Arrow) - Skip the rest of the function and return to the next instruction in the calling function or method after using Step Into.

Please note that as you step through your app, inspect variables relevant to your bug and watch for unexpected values.


Other debug actions that appear on this bar include:

  • Debug View Hierarchy (Screens) - Allows you to analyze the view hierarchy and all the UI objects that are currently active in the app.
  • Debug Memory Graph (Share) - Allows you to analyze the memory of the app and how everything connects.
  • Environment Overrides (Switches) - Allows you to override environment variables.
  • Simulate Location (Arrow) - Allows you to change the simulated location (i.e. Change to Paris vs Madrid).

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details