Auto layout: Hundreds of warning and several errors

Hi,


I'm starting to prepare my App for IOS 9 with Xcode 7. I have installed OS X El Capitain with Xcode 7 on my old White Macbook (my main workstation is a MacBookPro Retina 15" end of 2014).


I have transfered my project to the White MacBook and when I open it, my storyboard (around 50 view controllers) in XCode 7 has hundreds of warnings (Expected: width: xx Actual width: yy), usually there's a difference of 1 or 2 pixels between Expected and Actual.

In my storyboard on XCode6 on the MacBookPro I have no warning at all. If I remember correctly I already had the same type of issue with XCode 6 when I was moving my project from the MacBookPro to the White MacBook.


Is it a known issue? is there a fix for this? I would like to avoid to updates all frames from all my VCs.


I have also some errors, requesting to increase the vertical compression resistance for several labels, is there additional constraints that requires this compared to XCode 6?


Regards,

Replies

Xcode 7 is using a different SDK, and the default system font metrics may have changed. The intrinsic content size of your labels etc. may be different. I haven't started using Xcode 7 yet but I have seen similar issues when updating to the latest Xcode from time to time.


I usually just "update frames" on the storyboard and don't worry about it.


But if you are getting *errors* related to label size changes, that to me indicates you have redundant constraints somewhere. In most cases you should have exactly one constraint each to specify the horizontal and vertical position, and a maximum of one to specify the horizontal and vertical size (if it's something like a label or a switch which has an intrinsic content size, then you don't need explicit constraints to specify the size).

Thanks for the answer.


I don't think I have redundant constraints because everything is fine with Xcode 6 (no warnings, no errors). I will update again all my frames from all my VCs but it's quite long with more than 50 VCs. Is there a trick to do it on all VCs in one shot?

Just because there are no warnings or errors with Xcode 6 doesn't mean you don't have (potential) conflicts. Xcode only detects actual conflicts and ambiguities. For example, if you have a label with constraints to container top and bottom of 20 points and the actual height of the label is also 20, then you've dictated that the container is exactly 60 points tall. Maybe elsewhere you have constraints that also effectively dictate that the container is 60 points tall (not depending on the height of a label). Now, the system font changes and the label is 22 points tall (or 19 or whatever). Well, now the constraints conflict where they didn't before. One set is dictating that the container is 62 points tall while the other is still dictating that it's 60.


The general problem is that you've over-constrained your layout. You haven't left enough flexibility to let it adjust based on different system fonts, etc.

I am having the same issues with XCode 7 auto sizing. Apple seem to have made substantial changes to the way it works from XCode 6 and it seems almost impossible to use. I would like to know who else is experiencing this problem, it may be only with existing projects, I haven't tried creating a new project in 7 and seeing of the problems are the same.


The warnings you are getting for your constraints happen even if you remove your constraints and add them again. The only way to clear the warning is via Editor -> Resolve Auto Layout Issues -> Reset to Suggested Constraints. The problem for me is that leads to a different layout result under 7 than it did in 6 and so I can't achieve a matching layout for a new VC I am trying to add. Either there is a bug and it simply isn't working (that's my view) or their is something else going on I don't understand. In general I found Auto sizing under XCode 6 to be pretty straight forward and more importantly I could repeat the structure from one view controller to the next to achieve to same layout but now its just behaving very strange. Literally if I add 10 elements to a VC and then one by one add constraints that I have always used, every element will have a yellow box around it indicating a warning and the only way I have found to clear it is to Reset Constraints via the Editor menue. Once you do that XCode adds a bunch of constraints that you may not want and some times moves things slightly and you end up with alignment issues that never occured before.


Anyway, I would like to hear from others if they are experincing problems. My guess is no on is using auto sizing because no one seems to be asking these questions.

I thinks XCode 7 has more checks than XCode 6. Which means "new" errors may be detected.

I had some conflicting constraints that I could only fix by changing the priority level of some of the constraints in, conflict (750 vs 1000) so that AUtolayout could manage it.

Storyboard warnings are drivng me mad.

They re-appear suddenly. And I have to "fix" them again walking through storyboard and clicking "Update Frames".

Xcode 7.2.1.

I agree but the problem is if you update frames it moves things and so if you have several fields and you want them all positioned so the left hand edges are aligned Update Frames moves the field slightly and breaks the layout you are trying to achieve. I don't understand yet what is going on here. Autolayout used to be pretty straight forward and quick to use under Xcode 6 so why has it changed so much now? I am guessing that there is a migration issue with Apps built with previous version of Xcode.


If I add a new VC and add labels and text fields then add contraints it all works fine but every object in the VC has yellow boxes around it and a warning. It just seems broken to me.

With XCode 7.3, I am now seeing frame warnings for some layouts that were fine in 7.2.

7.3 has a major bug with autolayout and stackviews.

was this ever resolved? i'm seeing the exact same thing and have yet to find a good solution that will eliminate the yellow box around each and every object i had to the VC. i believe this is leading to issues on my beta testers devices...my simulators in xcode show ok but the users phone is acting differently.


- the app lady