Search code examples
xcodeautolayout

Find a constraint using the hex code


I have some issues with auto layout, where the console says there are conflicting constraints. However, when Xcode attempts to fix the issue, everything works as intended. In the console it reports

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe578db22f0 V:[UILabel:0x7fe578d9b200'Label'(32)]>

I want to find the constraint mentioned: "0x7fe578db22f0" and delete it manually.

Is there anyway to find it by using that hex code? And if not, can anyone suggest a way to fix my issue? I have a lot of constraints and it would be very difficult to go through and test each one.


Solution

  • If the question is merely how to identify which view that constraint is associated with, the easiest way is probably using the view debugger. So, run the app and click on the "debug view hierarchy" button. Then examine your view hierarchy in the left panel (narrowing it down by searching for view type, if you want), until you see a constraint that looks like the one in question. And by choosing the object inspector, you can confirm the address of the constraint in question.

    view debugging

    Now that you've identified the precise constraint and view in question, the tracking down of its creation in the app should be much easier.