Xcode Debug View Hierarchy: Unable to Capture View Hierarchy

Unable to capture view hierarchy while running UI Tests

You have an issue because you're trying to Debug View Hierarchy of a wrong process. In UI testing, there are two processes. First is UI Test runner and second is your app. Both are attached but debug view is handling first process by default which is runner not the app. And you can't have view hierarchy for a runner. Thus, this message:
Sample Image
Please note which process is selected.

While the UI test is launched, you can change this selection to the app itself and hit the Debug View Hierarchy button which will successfully capture your app:
Sample Image

This is a little bit tricky though. The runner process is still active and will kill/relaunch your app even if it's in view debug mode. I could capture the hierarchy only while testing single test method.
It's likely you will have to put some waiting code to slow down the test execution to actually have time to hit the Debug View Hierarchy button.

Xcode - can't find Debug View Hierarchy button

On the left side of the debugger, in the toolbar below:

Debug View hierarchy

It is the second icon from the right in the image. It might be black or greyed out depending on whether Xcode is in focus or not.

It works fine on device and simulator. Either click it to break or break using a breakpoint/debugger and use it.



Related Topics



Leave a reply



Submit