Is there a GUI tool that inspects the view hierarchy of an iOS app? I'm thinking about Webkit's web inspector or similar tools. I'm looking to debug layout issues, like views having the wrong position or size, or a child not being properly contained in its parent. Currently I have to add asserts that test these various conditions by hand, or set different background colours on different views, and as you can imagine, that's a really tedious way to go about it.
I looked at Instruments's UI recorder
, but that only records and plays back UI actions` and, in any case, works only for Mac apps.
Is there a better solution?
The approved answer no longer works for me, using Xcode 8 and Swift 2.3. Here's what does work for me:
po UIApplication.sharedApplication().keyWindow?.recursiveDescription()
This question is old but let me put info here about new tool which I develop: https://github.com/glock45/iOS-Hierarchy-Viewer
This dumps all in debug window.(Hard to read tho) :( Working on iOS 10, Xcode 8.3.3
Xcode 6 now has 3D view hierarchy inspection built in like Reveal App and Spark Inspector.
Click on the "Debug View Hierarchy" button while your app is running to pause execution and inspect the views at the current moment.
More info at Apple's documentation.