Search code examples
iphoneobjective-cipadlocalizationxcode4

iOS universal app localization xcode 4. bug?


well, i've just faced with localization problem on my projet and decided to make an experiment to reveal the problem:

experiment:

  1. create universal iOS application;
  2. change the text on main windows from "My Universal iPhone (iPad) App" to "Hello" both for MainWindow_iPhone.xib and MainWindow_iPad.xib files;
  3. build and run app in iPhone and iPad simulators - both displaying "Hello" message - everything is fine;
  4. add spanish localization for MainWindow_iPhone.xib and for MainWindow_iPad.xib (english localization was already there)
  5. change the text on main windows from "Hello" to "Hola" both for spanish version of MainWindow_iPhone.xib and MainWindow_iPad.xib files;
  6. change language in simulator to spanish;
  7. build and run app in iPhone and iPad simulators - both still displaying "Hello" message - what?!?!?!

fix:

  1. open project properties and go to "build phases" tab;
  2. in "copy bundle resources" add xib files: locate MainWindow_iPhone.xib and MainWindow_iPad.xib files in es.lproj directory of project and add them
  3. build and run app in iPhone and iPad simulators - both displaying "Hola" message - OK

well, what conclusion can i make? when adding new localization to xib file, xcode is forgetting to add this file to copy bundle resources target. so after running app on different localization (spanish in example) iOS can't find spanish localization (of course, Xcode forgot to copy it!!!) and load english version of xib.

manual adding localized versions of files makes mess in the project tree - added files will be displayed in project hierarchy, but they are already displayed when we expand xib file with localizations. (in example we will have MainWindow_iPhone.xib and MainWindow_iPad.xib in project structure tree, but at the same time they are available in iPhone and iPad file groups after expanding localized MainWindow_iPhone.xib or MainWindow_iPad.xib files)

or am i missing something cruicial?


Solution

  • If you manually add resources to Xcode, you'll often need to (K)lean your project to rebuild the links. Command-K should do the trick.

    I can't remember having to do this in Xcode 3 and it may already be fixed in later version of Xcode 4.