5

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.

2 Answers 2

8

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.

2
  • I know this is a late comment on an old post but I cannot find any other answers like this. Is there any way to search ? 'ctrl - f' ? or do you have to go one by one through each constraint Commented Mar 4, 2019 at 14:28
  • 1
    @JulianSilvestri - You can, at the bottom of the panel on the left, put the address in the filter box, and that can sometimes can find it. The other trick is to go to the storyboard select the constraint in the document outline, and then go to the size inspector, and give you constraints respective “identifiers”, i.e. give them meaningful names. Then, the messages in the console will show those meaningful names when printing out the constraints with errors. Finally, sometimes they show up in the “Issue Navigator” » “Runtime”, and you see some types of constraint issues there.
    – Rob
    Commented Mar 10, 2019 at 1:40
1

Add UIViewAlertForUnsatisfiableConstraints symbolic breakpoint help you debug autolayout easier !

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.