31

I am currently testing out Xcode 9 beta 3 at the time of this writing.

When viewing the storyboard I am receiving a list of warnings indicating that in other languages/regions my fixed constraint will pose an issue.

The application is fairly complex and many views are experiencing these warnings.

The warning is:

Certain autolayout constraint combinations may result in an appropriate layout in the current development language but will pose issues in other languages and regions.

I know that the app will not be used in any other languages anytime soon.

Is there any way to turn just this warning off? It sounds silly but I can not stand seeing all my views with the yellow the warning icon and count at the top (110 warnings!)

localization issue

allenh
  • 6,582
  • 2
  • 24
  • 40
Simon
  • 6,413
  • 6
  • 34
  • 57
  • https://stackoverflow.com/questions/33111048/how-to-suppress-or-ignore-all-warnings-in-xcode – LC 웃 Jul 11 '17 at 16:42
  • 1
    The yellow triangles in your screenshot are clickable, and provide a popover with suggested resolutions. Resolving the issues is the ideal solution here. These issues have been refined in later Xcode 9 beta builds, as well as Xcode 9.1 There is not currently a way to just turn off the warnings, other than un-localizing your document. Please do file bugs (at bugreport.apple.com) for any warnings that appear to be incorrect, and attach a sample document. – Quinn Taylor Oct 02 '17 at 17:11

4 Answers4

77

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

  1. Move the storyboard from the Base.lproj folder up one level via Finder
  2. Delete the storyboard reference from your project via Xcode
  3. Drag and drop (or otherwise re-add) the storyboard to your project
  4. Verify using the File Inspector that the storyboard no longer has base localization

     

Pictorial Walkthrough

Xcode defaults to having storyboards "prepared" for localization

Xcode default storyboard folder structure

     

Move your storyboard files out of the Base.lproj folder to prevent the warnings

Desired folder structure

     

Delete the file reference

Delete the file reference

     

Re-add the storyboard

Drag and drop the file back into the project enter image description here

     

You'll see the "Localize..." button when you've succeeded

Yay! No more warnings

     

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

allenh
  • 6,582
  • 2
  • 24
  • 40
  • I moved the storyboard file up a level in the project through Finder but still the same issue. Do I need to delete it through Xcode and then add it to the project in Xcode? – Simon Jul 11 '17 at 18:03
  • 1
    You need to move it up a level using Finder. It will be inside of a folder called Base.lproj or English.lproj or some other language dot lproj. Using finder, move the storyboard file out of that folder. At this point, Xcode won't know where the file is, so delete the reference and re-add the file by simply dragging and dropping. – allenh Jul 11 '17 at 18:04
  • Awesome. Will this effect anything in the long run? I will be able to move it back into the `Base.lproj` directory when I choose to do so? Just making sure before I proceed with this option. – Simon Jul 11 '17 at 20:04
  • If you decide you'd like to support localization, just press the **"Localize..."** button and Xcode will move your storyboard into the lproj folder that you choose (it will prompt either Base or your development language). – allenh Jul 11 '17 at 20:21
  • @Simon Let me know if this worked for you. And if it did, please accept! – allenh Jul 11 '17 at 22:01
  • @alien humphreys : When I localize again after this process. It will showing same Waring again. – Mitesh jadav Sep 23 '17 at 08:16
  • @Miteshjadav The question and answer are about disabling the warning. If you have a storyboard that actually needs to be localized, you should update your layout to correctly accommodate differing lengths of languages. Things you can do include: set the *Lines* parameter to 0 allowing the label to grow vertically, use fixed leading and top constraints with flexible trailing and bottom constraints. If you'd like to post a specific question, I'm sure you'd get an answer regarding the best way to resolve your situation. – allenh Sep 23 '17 at 16:46
  • I'm trying this method but keep getting the `terminating with uncaught exception of type NSException` when I try running it. My steps: Move Main.storyboard with Finder outside of Base.lproj. Then open project with Xcode. Delete old Main.storyboard since it's location is invalid. Then drag file from Finder to Xcode. Compile and Run. – Jason Brady Oct 11 '17 at 22:44
  • @JasonBrady Is there no other explanation with the exception? Have you tried cleaning your project/derived data after the move? – allenh Oct 12 '17 at 17:38
  • @AllenHumphreys, Turns out I needed to select the check box in `Target Membership` But now I'm all good without Localization. – Jason Brady Oct 12 '17 at 17:40
  • It seems to be working for me. Thanks a lot. Upvoted..!! – NSPratik Nov 28 '17 at 09:22
  • Tap should be on Folder icon, not on arrow. – NSPratik Nov 28 '17 at 09:30
  • 1
    @NSPratik Thanks for that, I went to update the instruction image and found that Xcode 9.1 no longer works with that method of fixing the file reference. I updated the instructions with a delete and re-add solution that **should** be more clear. – allenh Nov 28 '17 at 16:54
  • my issue got resolved but i want to ask that after this should i need to move the storyboard file back to bass.lproj folder?? – TheTravloper Sep 28 '18 at 05:39
  • @HappilyHemu No, you should not move it back. If you do move it back, the warnings will re-appear. They should only be in `Base.lproj` if they are localized. If you'd like to localize them later, press the `Localize` button mentioned in answer. – allenh Sep 28 '18 at 19:28
4

Assuming your app is not localized, you need to restore the Localize setting in your storyboard. One of ours was set to English. Uncheck the English box, or whatever yours is set to. The storyboard is in a folder with the language code, en for English. Unchecking this box will remove it from the project directory since the App is no longer looking for the en folder. Find the storyboard in the finder folder, move it from the en folder, then drag it back into the project. Make sure the Target Membership is checked. Clean, close, open, force quit, etc as necessary and you should be good to go! We had 360 warnings in one storyboard so it was nice to get this resolved!

enter image description here

NSPratik
  • 4,714
  • 7
  • 51
  • 81
John
  • 538
  • 4
  • 18
2

You can also remove the Localization Issue warning by simply embedding the label or button in a transparent view. Then remove the fix width constraint from the label or button and set it to that container view instead.

By using a container view you can silence the warning and still be able to localize the storyboard. Sometimes you need to have a label or button with a fix width even if the language is going to change, and if you are sure the fix width is big enough it shouldn't be a problem but Xcode doesn't know that, that's why you get the warning ;-)

boherna
  • 659
  • 8
  • 7
1

An easy solution: turn off Respect Language Direction for each problematic constraint.

See https://stackoverflow.com/a/45764271/201828.

phatmann
  • 18,161
  • 7
  • 61
  • 51