Xcode 9 - "Fixed Width Constraints May Cause Clipping" and Other Localization Warnings

Dave G picture Dave G · Jul 15, 2017 · Viewed 57.3k times · Source

I downloaded the new Xcode and in Interface Builder I'm having a ton of problems with warnings that say things like:

Fixed Width Constraints May Cause Clipping

It looks like this:

enter image description here

I do have localization for several languages and I understand the warning that in another language a label's size may change, but my app doesn't have this problem. I ran and tested it in Xcode 8 yesterday, it was fine. I don't want to spend hours and hours adding pointless new constraints.

Any suggested solutions?

Answer

Shades picture Shades · Aug 19, 2017

I was getting the same warnings even without multiple languages in my app, which led me to find out what was really going on. . .

There are a few different things going on here. I was able to silence the fixed-width warnings in my own app by changing the width of the object spacings from fixed width to greater than or equal or less than or equal.

This can be done by selecting the object in interface builder, going to the size inspector and changing it there:

enter image description here


Or, select the constraint from the document outline, go to size inspector, and change it there:

enter image description here



As far as the warning at the top of your screenshot:

Fixed leading and trailing constraints with a center constraint may cause clipping

Here is a screenshot from my own app in which I was getting the exact same warning:

enter image description here

I had the label with the @ sign set to leading and trailing to the buttons but also to align the center with the rating label. Once I removed the center alignment constraint, the warning disappeared, but I was left with an improperly laid out set of objects.

It is then that I resigned myself to embrace the Stack View. As annoying as it is to use, when you get all of the constraints and settings right, it lays out beautifully and with no warnings.


Edit

As Repose writes in the comments, sometimes simply adding >= 0 will be what you need, as you are making sure two elements do not overlap.