Xcode 9 - Fixed Width Constraints May Cause Clipping and Other Localization Warnings
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:
Or, select the constraint from the document outline, go to size inspector, and change it there:
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:
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.
How to fix Fixed width constraints may cause clipping warning in Xcode?
If you are showing a long text in the button, it will clip it. One way to silence the warning is setting the constraint to "greater than or equal". Select the constraint, click "Edit", then select ">=" next to "Constant". Or double click it (or select it in the storyboard pane) and select "greater than or equal" at the "relation" row.
Check out @shades' answer for more details.
Xcode 9.2 - “Fixed Width Constraints May Cause Clipping” Warning
This warning says that if label got bigger text than rest of text will cut which does not fit in fixed width.
>= Means the width of the label will become flexible if label got bigger text; the minimum width will be the one you have set.
<= Means the maximum width of the label will be the one you set.
More convenient way to set label constraints is to set leading, trailing, top and bottom constraints instead of setting width constraint where, trailing space will have >= constraints with the value for minimum space required between parent view and label / horizontally near by view and label.
Hope this helps :)
How to resolve the Storyboard's warnings on Xcode?
- Give Trailing to Hello, Label with World! label like below image give Constant 8 (What minimum gap you need) to Trailing constraint and change Relation to Grater than or Equal.
Alternative labels giving Fixed width constraints may cause clipping warning why?
1.Give the left sided labels horizontal content hugging priority of 252.
2.Give the right sided labels horizontal content hugging priority of 251.
3.Give horizontal spacing of 8 between the left sided and right sided labels.
4.Remove fixed widths for all labels.
5.Align leading and trailing of all the left sided labels and just the trailing of all the right sided labels.
6.Give vertical space to left sided label from right sided label of the previous row.
7.Vertically center align the left sided and right sided label in the same row.
All your warnings will disappear.
Xcode 9 - Localization Issue Warning Storyboard
The source of the unwanted warnings is that Xcode defaults to having storyboards "prepared" for localization. They are "prepared" by setting them up using base internationalization.
To completely disable this warning in a particular storyboard, you need to let Xcode know that the storyboard should not be considered localizable. The easiest way I was able to do this was to simply move the storyboard file from the Base.lproj
folder up one level and re-add the file to the project. Once I did that, the warnings went away.
Steps
This process should work with old and new projects. Tested on Xcode 9.1 using a project created with Xcode 9.1
- Move the storyboard from the
Base.lproj
folder up one level via Finder - Delete the storyboard reference from your project via Xcode
- Drag and drop (or otherwise re-add) the storyboard to your project
- Verify using the File Inspector that the storyboard no longer has base localization
Pictorial Walkthrough
Xcode defaults to having storyboards "prepared" for localization
Move your storyboard files out of the Base.lproj folder to prevent the warnings
Delete the file reference
Re-add the storyboard
You'll see the "Localize..." button when you've succeeded
If you want to localize in the future
Just tap the "Localize..." button and follow the prompts from Xcode. Additionally, you'll actually need to address the warnings that Xcode is telling you about. There are various ways to address them, I recommend this question to get started.
For a video demonstration of the process, watch this screen recording
Related Topics
Invalid Swift Support - Files Don't Match
In Swift, How to Avoid Both Optionals and Nil Object References
Custom Installed Font Not Displayed Correctly in Uilabel
How to Detect Network Signal Strength in iOS Reachability
Generate a Random Float Between 0 and 1
How to Opt Your iPad App Out of Multitasking on iOS 9
iOS How to Set App Icon and Launch Images
Uialertview First Deprecated iOS 9
Scroll Uitextfield Above Keyboard in a Uitableviewcell on a Regular Uiviewcontroller
Check If a Uialertview Is Showing
Insert CSS into Loaded HTML in Uiwebview/Wkwebview
Behaviour for Significant Change Location API When Terminated/Suspended
How to Get Audio Volume Level, and Volume Changed Notifications on iOS
In iOS, How to Store a Secret "Key" That Will Allow Me to Communicate with My Server
Uiscrollview: Paging Horizontally, Scrolling Vertically
Presentviewcontroller:Animated:Yes View Will Not Appear Until User Taps Again