How to debug your view hierarchy properties using Xcode

If you ever want to see what the Xojo view classes do concerning layout, hidden items etc, you may be able to use Xcode’s View Debugger for that.

Here’s how it could look when you look at your Xojo app’s window:

On the right you see my app’s main window, on the left Xcode’s debugger view outlining all the native Mac view components.

Note how, for each native NSView, there’s a Xojo subclass of it that helps Xojo to control it and handle the events, routing them to Xojo’s model.

To get to this, I did the following steps:

  1. I am on High Sierra
  2. I am using Xcode 10.1
  3. I create a new project in Xcode: “Cocoa App”, ObjC, and uncheck all options (e.g. no storyboard).
  4. I launch the Xojo app I want to explore.
  5. With the project open in Xcode, from the menu: Debug / Attach to Process, choosing my Xojo app.
  6. Wait a few seconds for Xcode to learn the app’s details.
  7. Click the “Debug View Hierarchy” button in the debugger view (circled in red on the image above).

May also work with newer macOS and Xcode versions, though I haven’t tried yet.

5 Likes

Norman had described the same feature a while ago, too: Fun things to do with Xcode – Writings from the sticks

2 Likes

This is a great trick.

For anyone wanting to do the same with an iOS App, https://revealapp.com/ has similar features.

2 Likes

Also, it appears one needs to disable SIP, or at least use the “–without-debug” option like this: “csrutil enable --without debug”.