Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I inspect the view hierarchy in iOS?

People also ask

How to see view hierarchy Xcode?

Now run the program as normal, then in Xcode go to the Debug menu and choose View Debugging > Capture View Hierarchy. After a few seconds of thinking, Xcode will show you a screenshot of your app's UI.

How do you view a hierarchy?

In the menu bar, select Window > Open Perspective, and then click Hierarchy View.

How do I Debug UI in Xcode?

Go back to Xcode and click on the Debug View Hierarchy button in the Debug bar. Alternatively, go to Debug\View Debugging\Capture View Hierarchy. Xcode is now interrupting your app and handing the reigns to the debugger, just as if you had paused your app with the pause button on the Debug bar.


I don't know if there is a GUI view inspection tool, but I have had some luck with the debugging method on UIView: -recursiveDescription

if you pause the program in the debugger and input this into GDB (Edit: also works in LLDB)

po [[UIWindow keyWindow] recursiveDescription]

You get a printout of your entire view hierarchy. You can also call it on a specific view to get a printout of the view hierarchy of that view.

It can be a little tedious to wade through the info you get out of it, but it has proved useful to me.

Credit goes to this blog post which talked about this method and also linked to this helpful, but rather hard to find Apple tech note.


Xcode 6 now has 3D view hierarchy inspection built in like Reveal App and Spark Inspector.

enter image description here

Click on the "Debug View Hierarchy" button while your app is running to pause execution and inspect the views at the current moment.

enter image description here

More info at Apple's documentation.


Reveal app screenshot

Oddly enough, now there is another option, http://revealapp.com/, which as of this post is in an open (free) beta. As you can see it's another visual inspector.

EDIT 2014-04-05: Reveal is out of Beta and no longer free. There is a 30-day trial, however.


This question is old but let me put info here about new tool which I develop: https://github.com/glock45/iOS-Hierarchy-Viewer enter image description here