Can I suppress localization issue warning about trailing constraint?

Xcode 9 is now giving me a lot of warnings about “Trailing constraint is missing, which may cause overlapping with other views.”


For various reasons, my game will not be localized. While I guess the suggested constraints are safe, they don’t really feel true to the spirit of my layout (plus the more constraints exist, the harder it is to change things).


Is there a way to suppress these warnings on a per-project (or per-target) basis?

Accepted Reply

The solution is to “de-localize” the stryboad, afterwhich, the Xcode's File Inspector's Localization pane will show a “Localize…” button instead of the typical Base/English/etc checkboxes. The trick involves moving the storyboard (using the Finder) out of the Base.lproj folder (up one directory), then removing and re-adding it to Xcode's Project Navigator. Full instructions on the StackOverflow post where I just learned how to do this: https://stackoverflow.com/questions/45039846/xcode-9-localization-issue-warning-storyboard/45040394


I'm in a similar boat in my project— I may want to localize some of my views down the line, but not my DebugMenu.storyboard. The DebugMenu is intended for me only, and won't even ship in the final Release builds. So just like you, I will never need to localize it and the unnecessary added constraints make it more work for me to modify.


I hope this helps you (months after your post) or others with the same problem. ;-)

Replies

Compiler just need to have a consistent set of constraints.


If you want to do this rapidly, you can "add missing constraints" in IB, after selecting the view of the view controller.

The constraints are fine. The warning is basically because if I localized to German, there is nothing that prevents UILabels from running into other stuff. It’s a reasonable warning for people who are localizing.


But I am never going to localize this game.

Effectively, if trailing is missing, you would get a problem when localizing, which you do not plan to do.

But that could happen also if you change the text one day for something longer.


But what would be the problem to add a trailing constraint, if silencing the warning is important to you ?

You write : While I guess the suggested constraints are safe, they don’t really feel true to the spirit of my layout (plus the more constraints exist, the harder it is to change things)

  • I understand the second point (the more constraints, the more complex it is)
  • but not the first : how does a constraint change the spirit of your layout ?


Edited Aug 3

May be you can create your own custom compiler flag :

h ttps://stackoverflow.com/questions/43555004/how-to-suppress-warnings-in-swift-3/43556911

The spirit is that something is left-aligned, but has no real layout relationship to other elements that are to the right of it. The additional constraint would be to satisfy a situation that will never happen, and makes the intent harder to determine.

What I am asking for is: what compiler flag can I put on this .xib file so I can suppress the warning because in this case, I do know what I am doing?

The solution is to “de-localize” the stryboad, afterwhich, the Xcode's File Inspector's Localization pane will show a “Localize…” button instead of the typical Base/English/etc checkboxes. The trick involves moving the storyboard (using the Finder) out of the Base.lproj folder (up one directory), then removing and re-adding it to Xcode's Project Navigator. Full instructions on the StackOverflow post where I just learned how to do this: https://stackoverflow.com/questions/45039846/xcode-9-localization-issue-warning-storyboard/45040394


I'm in a similar boat in my project— I may want to localize some of my views down the line, but not my DebugMenu.storyboard. The DebugMenu is intended for me only, and won't even ship in the final Release builds. So just like you, I will never need to localize it and the unnecessary added constraints make it more work for me to modify.


I hope this helps you (months after your post) or others with the same problem. ;-)