How do I inspect the view hierarchy in iOS?

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.


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


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.


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.