Debug View Hierarchy Does Not Render UI

Why these layout issues occur when debugging view hierarchy while the UI layout in simulator is OK

Well, I'm not an expert with constraints, but I do see one "correctable" issue and one "that's just weird maybe it's a bug" issue.

As I understand it, auto-layout will try to satisfy the constraints -- even if they are ambiguous. If it fails, then you see the error message in the console, usually along the lines of "will attempt to satisfy by breaking..."

So the warning information you see in Debug View Hierarchy is more informational than "fix this error" directive.

That said...


You have accountLabel and timeLabel constrained relative to each other, but they both have the same Compression Resistance. So, as long as the amount of text in each label would "fit", all is OK.

But suppose the accountLabel gets a text string of "This user name is too long to fit here"?

Should it look like this (I use background colors to help see the frames):

Sample Image

or like this:

Sample Image

That's why the horizontal position and width is showing as "ambiguous".

You can fix that issue by adding one line. Assuming you want accountLabel to be truncated:

    accountLabel.setContentCompressionResistancePriority(749, for: .horizontal)

will do the trick. The default is 750, so that line tells auto-layout to give timeLabel the higher Resistance.


The Height and Vertical positions showing as ambiguous don't seem right. I don't see anything wrong with the constraints.

If I use the same font for all three labels? No ambiguous warnings.

If I use a different font size for the timeLabel (as you show in your images), now there are warnings in debug view hierarchy.

Except... If I scroll so the cells are reused? The warnings have gone away!

EDIT: As the OP states in his comment, the Vertical ambiguity can be eliminated (prior to scrolling) by giving different Content Hugging Priority values to accountLabel and contentLabel.

Since the default Hugging priority is 250:

    accountLabel.setContentHuggingPriority(249, for: .vertical)

Clears that warning.

I'm not convinced it's necessary... but it does appear to do the job.

View shows up in Debug View Hierarchy, but NOT on device/sim

I'm stupid — I fixed it. I'm not sure why it shows up as on top in the view debugger, but it was behind another UIView.

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.

Xcode debug view hierarchy shows blank white screen

I think that Xcode's view debugger is not mature yet.

Your bug frequently happens to me when using complex view hierarchies.

A good workaround is to use Spark Inspector (it has a free full-feature trial) for now, until Apple fixes the issue.



Related Topics



Leave a reply



Submit