Developer Tools for UI Debugging

Dmytro Anokhin
Oct 18, 2017 · 5 min read

User Interface of a modern app is a complex structure. Sophisticated relationship between UI elements, layout, and drawing makes debugging process harsh. Knowing available tools can reduce hours of debugging and make process of discovering issues trivial.

In this article I would like to do a quick review of UI debugging tools provided by Apple.

View Hierarchy Debugger

View Hierarchy Debugger provides the ability to inspect and understand the UI hierarchy.

Your app’s hierarchy, views, constraints, and view controllers, displayed as a hierarchical list. Object inspector and size inspector. And even interactive 3D model. All built in in Xcode. How cool is that!

Debug View Hierarchy button is located in the debug bar. Xcode pauses your app in its current state.

View debugging is available for iOS, tvOS, and macOS, simulator and device.


If you prefer the console over visual tools, you’ll be thrilled to know that UIKit includes nice logging APIs. Small issue — this APIs are private. But we’re not using debug functions in release anyway.

— Print UIView hierarchy in a convenient form:

Each UIView node includes layout and drawing information, CALayer, and additional specific fields.

Similar method for UIViewController includes presentation information:

  • | symbol indicates child view controllers;
  • + stands for modal presentation.

_printHierarchy method is especially useful when called on the rootViewController of a UIWindow:

Worth mentioning — in Swift the console behaves differently depending on the case:

  • when program execution paused from the debug bar we can use Objective-C syntax for messaging, e.g. po [view recursiveDescription] will work (with condition that you have access to the view variable or know the address)
  • when lldb stops on a breakpoint, you must use Swift syntax: po view.recursiveDescription()

Of course, you won’t be able to use private APIs in Swift without exposing them publicly:

Note, po command prints special characters in String. NSString when printed looks more convenient.

Now you should be able to print both hierarchies in Swift:

Instruments — Core Animation

Moving from inspecting UI structure to optimizing performance. First thing we should to do is measure Frames Per Second. Human perceives app as responsive when it can work at ~60 FPS. This is our goal.

Core Animation template measures graphics performance of the app. For this example we’re focused only on rendering performance. My app is a UITableView with custom cells. For now it only displays section and row.

I notice scrolling performance is not that smooth. Profiling the app with Instruments reveals that my performance is far from 60 FPS. When I scroll (seconds 4–23) the performance drops to 44 FPS — 16 FPS below the goal, 27% slower.

I suspect the issue is with my cell rendering. With Color Blended Layers debug option enabled I can get better understanding of what is happening.

Color Blended Layers shows view layers that are drawn on top of each other with blending enabled.

To understand why this is a problem, we need to know how final image is created. Final pixel the user see is a composition, blending of top and underlying pixels at the coordinate. This mean that every view layer must be rendered to create final image. When view layer is opaque, blending can be optimized by not drawing underlying layers.

To create rounded corners and shadow I use CALayer properties:

This makes parts of my view layer transparent, causing unnecessary blending. Because the background is color fill, rendering can be optimized. I will set solid background on my views and use background image without alpha:

Simple trick allows me to get rid of blending:

Performance is now 58–59 FPS and scrolling feels smooth.

Best part, you have quick access to Color Blended Layers from iOS Simulator.

Accessibility Inspector

UIKit provides impressive support for accessibility and VoiceOver in particular. When things don’t work way we expect, Xcode provides Accessibility Inspector.

Besides debugging, the tool can perform audit of your app and highlight various issues, for instance Dynamic Type support.

Accessibility Inspector is hidden in Xcode > Open Developer Tool > Accessibility Inspector.


Pixie will help you implement pixel-perfect design. This tiny tool allows you literally inspect every pixel of your app:

Pixie can be downloaded from Apple Developer website (Xcode > Open Developer Tool > More Developer Tools…) in Additional Tools for Xcode package.

Thank you for reading. If you like the article, please follow me and share.

Read my latest article Concurrency in Swift: Reader Writer Lock.

Show authors more ❤️ with 👏’s

And hope to see you next time 😊

Dmytro Anokhin

Written by

iOS Developer, here to share best practices learned through my experience. You can always reach me on linkedin: