In xcode developers can pause/break the execution of running app and can examine the state of program.
Here's how to pause running programs:
Just open any file in which we want to put breakpoint and click on the line on gutter at left side where we want to pause execution.
So here we placed breakpoints on line no 21 and 38; when execution reaches at line 38 Xcode paused execution and shown green line on that line.
Debug Gauges gives us an glimpse of CPU usage, Memory usage and at bottom the execution stack with Threads and function names. We can know which stack or sequence of functions lead execution to this line of break.
Variables View gives all the details of states and values of all variables in the scope of breaded line. We can see their values, memory addresses, properties of instances and their details.
Console can be used to print value of any variable that is in scope. Using PO
command we can achieve this.
Debug Bar has controls for breakpoints.
Configure Breakpoint:
We can even have more control on breakpoints.
Delete are Disable straightforward functions.
Reveal in Navigator takes us to Breakpoint navigator where all the breakpoints from project are listed as File Navigator.
Edit Breakpoint is something we should used more often for detailed debugging. We can configure breakpoints using this function. We can conditions and actions to breakpoints as:
As shown in image, that breakpoint will be paused only if path != nil
. If this condition is true then po _routeStartLocation
action is executed and mentioned earlier po
will print value of _routeStartLocation
on console.
Form detailed explanation, follow this detailed link.