Hi 👋 I'm Simon Støvring, a developer with a passion for iOS. I build apps like Runestone, Scriptable, Jayson and Data Jar.
Running Xcode's View Debugger While Interacting with the Simulator
I often need to inspect an app's view hierarchy while interacting with it in the simulator. For example, the other day I needed to check out the view hierarchy while the floating cursor was active. You know, the cursor you get by long-pressing the Space bar on the iPhone keyboard. I wanted to check the color of the floating cursor and the placeholder caret shown in the text.
It sounds simple enough, but it's surprisingly tricky. These views disappear as soon as the interaction ends. Starting the view debugger means switching away from the simulator to Xcode, which interrupts the interaction, causing the views to disappear from the view hierarchy.
To solve this, I created the shortcut below which uses AppleScript to quickly switch to Xcode and select the menu item at Debug › View Debugging › Capture View Hierarchy.
I've mapped the shortcut to a global hotkey (⌃⇧D), so I can run it directly from the simulator. The shortcut runs fast enough to capture the view hierarchy before the interaction ends.Get the shortcut from here and check out the video below to see it in action.
Earlier posts
Building Documentation for Both iOS and macOS Using DocC
April 16, 2023
Moving from 1Password to iCloud Keychain
November 21, 2021
Using an iPhone as My Webcam
August 8, 2021
Mint Mojito Iced Coffee Recipe
August 3, 2021