I am getting more than 50 auto layout constraint errors in xcode 6

220 views Asked by At

When I closed Xcode last night, I had no constraint errors and when I opened Xcode today, it showed me 58 constraint errors. The number of constraint errors increased and decreased till they came down to 33. I have experienced this in the past also. When I wanted to fix this issue in the past, I would simply uncheck Auto Layout and check it again and the errors would disappear. But unfortunately, I cannot do that now as size classes has to be disabled then and that messes up my entire application.

3

There are 3 answers

1
mars On

I started working on my iPad project with enter image description here

Next time when i opened my xcode project it had changed to enter image description here

and thus it showed too many constraint errors. I again changed it to Regular width and height enter image description here

and the errors disappeared. Check if your case is the same as mine.

0
Krish Wadhwana On

I am answering my own question because I found the solution :) I had a UIVisualEffect in my app. I just moved it to the back, and then back to the front, and the errors disappeared. Xcode does work in mysterious ways...

1
gyan On

You said

I would simply uncheck Auto Layout and check it again and the errors would disappear.

I think disabling it will remove all the constraints, that's why the errors would disappear. It doesn't really solve any problem.

A general rule for setting up constraints is to go from general to specific.

In my last application, I first set all the common constraints in Any Width | Any Height and then set constraints that are specific to landscape iPhone in Any Width | Compact Height. Then I set the constraints that are specific to iPad and portrait iPhone in Any Width | Regular Height

Setting constraints are indeed a painful thing to do, but they are worth it. Good Luck.