Once you’ve found a trouble spot, you can capture a frame and use the Xcode OpenGL ES Frame Debugger interface to pinpoint rendering problems and solve performance issues. You can use it to add and remove tags as well as to move resources between tags. Set Debug Process As to root if you are working on code that requires root privileges. Logging with NSLog is sent to the console as well. Disclosure triangles are at the far left of the row, followed by an identifying icon, the variable name, type, and value. The Energy gauge is available in macOS apps when running Xcode 6.3 and greater, and is available for iOS apps with Xcode 7 or greater. Detects data races at run time. The diagnostics pane allows a variety of additional diagnostic tools to be added to the Run environment. Replace deallocated objects with a “zombie” object that traps any attempt to use it.

Note: Xcode categorizes breakpoints that you create in the source editor gutter as “method” or “function” based on the context of the source code they are a part of.

For more information, see Services Implementation Guide. If a breakpoint is not in the ideal location, drag the indicator to a better location.

How to Add Your Swift Package to the Swift Package Index, Implement the Builder Design Pattern in Swift 5, Adapting Objective-C APIs to Swift With NS_REFINED_FOR_SWIFT. With this pane, you can set up arguments to pass on launch and environment variables for your app.

However, useful debugging options are configurable in the scheme editor as part of the Run action configuration. The green pointer and highlight on line 61 in the source indicates the location of the instruction pointer and the current line of code to be executed. Options pane.

The icons used in the variable list allow easy recognition of the variable kind at a glance.

Every project contains at least one target. Sort By.

A breakpoint placed at an inappropriate location is categorized as “generic/uncategorized”—these are usually unreachable points in the source code file, such as between functions or methods, placed by accident.

Add guard pages before and after large allocations. In the screenshot below, the Adventure iOS target of the Adventure project is selected in the project navigator, and the Adventure iOS target is selected in the project editor.

With the debugger running, you can use Debug > Attach to Process on a process that has been launched with debugging disabled, if needed. Watch “{variable}”. To share a breakpoint with other users, in the breakpoint navigator select the breakpoint you want to share, Control-click the breakpoint, and choose Share Breakpoint from the shortcut menu. Kinds of breakpoints. The illustration below shows the default layout of the Xcode debugger with the app paused at a breakpoint. Click to stop the current running task or app. The debug gauges monitor your running app. Terms of Use | On-demand resources are app contents that you download only when needed.

If the current line of code calls a method, step into starts execution at the current line, and then stops when it reaches the first line of the called method. Breakpoints are organized in a hierarchy by scope, then by containing file. Enable Thread Sanitizer. Select Debug option from XCode Menu. Watchpoints are breakpoints that don’t stop execution, they report the state of the variable they’re configured for each time that variable is used. You can inspect variables directly in the source editor with a datatips pop-up window, which shares the same display layout as the debug area variable view. You can set several options for a breakpoint, such as a condition, the number of times to pass the breakpoint before it’s triggered, or an action to perform when the breakpoint is triggered.

Filter bar.

The debug bar includes buttons to: Step over; that is, execute the current line of code and, if the current line is a function or method, step out to the next line in the current file, Step in; that is, execute the current line of code and, if the current line is a routine, jump to the first line of that routine.

A target specifies a product to build, such as an iOS, watchOS, or OS X app.

An option in the editor allows you to add the expression to the variable list in all stack frames. It is equivalent to using the LLDB po command. I have a new warning per every target after upgrading to Xcode 11.4: Invalid debug info found, debug info will be stripped. You can assign breakpoints to two other scopes: A breakpoint with User scope appears in all of your projects and workspaces, wherever that source file is used.

Simulate Location button. To customize how Xcode displays portions of the UI, choose Xcode Preferences > Behaviors.

You typically assign values for these settings elsewhere during the app development process, for example, in dialogs that appear when you create a new project.

page. Although you can use the debugger to pause an app at any time, it's helpful to set breakpoints before and even while your app is running so that you can pause it at known points where you have determined problems might be occurring. Selecting View Process by Queue changes the backtrace organization to show stack frames below the dispatch queue that created them. See Debugging the View Hierarchy for more information.

You specify which items to display using the pop-up menu in the lower-left corner.

Editing breakpoints. Watchpoints are managed in the breakpoint navigator. It is on by default. Copy. Debug area view controls.

Select Attach to Process. In the middle, you see the Editor. The variable name is followed by the variable value as generated by the data formatter for the variable type.

Allow you to adjust how much information is presented for each variable in the variable view list. The backtrace is displayed with each stack frame identified by an icon. Variable list. The debugging UI is dynamic; it reconfigures as you build and run your app. Note: For both of these View Memory modes, return to the source listing by pressing the back button, by choosing the stack frame in the debug bar’s jump bar, by clicking on the stack frame in the debug navigator, or by clicking the breakpoint in the breakpoint navigator. When they are colored gray, it means that the stack frame indicated is from the recorded backtrace and is not live in memory in the context of the paused app. Click the “enabled breakpoints” filter button to show only the enabled breakpoints in your project. Enable Main Thread Checker. If your attempt doesn't work, the compiler diagnostics are visible—you use them to fix up the expression for use.

Copies the selected variable’s representation displayed in variable view, allowing you to paste it as text. You can create breakpoints at any time, including when your app is running in a debugging session. For Swift, since you can overload function return types, the return type is a part of the mangled name and is generally available even without debug information, as long as the Swift modules are available. Picking a stack frame from the jump bar will bring the source, or disassembly if the source file isn’t available, into the source editor.

Print Description button. The debug area console is a command line environment that you can use to interact with an app or with LLDB.

You use the Control and Control-Shift modifier keys to call these alternatives. When the app is running during a debugging session, it can read from the console using stdin and output to the console using stdout and stderr. Datatips. They help you locate resources in your Xcode project, such as Swift files, issues, breakpoints, and more. Log Library Loads. Select a target in the project editor to modify the target settings in the Info, Build Settings, or Build Phases pane. Your input helps improve our developer documentation. You choose one to tell a device or the simulator to report that location to your app as it runs. Expressions used in the breakpoint editor, just like expressions used with the LLDB expression parser, need to be the correct return type before the expression parser can evaluate them. An OpenGL ES error breakpoint is a specialized type of breakpoint used in the Open GL ES debugging tools, it is a derivative of a symbolic breakpoint. This is …

For example, some existing schemas include http, mailto, and sms. Arguments pane. Enable Malloc Guard Edges. Xcode moves shared breakpoints into their own category in the breakpoint navigator; all users with access to the project will be able to use them. Application is installed either on a simulator or on the device. For instance, misplaced graphics on the screen, the wrong picture associated with an item, labels and text that are incorrectly clipped or placed—these are all examples of issues with an app’s view hierarchy. There are several different kinds of breakpoints, and they can be edited to add conditions, actions, and scripts. Show Types and Show Raw Values. Accessing Resources and Inspecting Elements, Creating and Rendering Custom View Classes, Adding On-Demand Resource Tags to a Target, Adding File Type and Service Information to a Target, Using URL Schemes to Communicate with Apps, Apple's Unsolicited Idea Submission Policy.