2

I'm trying to begin localization on a project, and I've already got an English version of Localizable.strings going. I'm now trying to add French to that file, which is creating an fr.lproj folder, as I'd expect. However, it's putting it in my project root, and I'd like it inside my project's Resources directory.

Xcode seems to have no interest in letting me move the file, and if I move it in Finder, it goes red in Xcode as expected, but doesn't let me click to locate the file.

I've tried moving it in Finder, then editing project.pbxproj in a text editor to add Resources/ in front of the only line in there that mentions fr.lproj/Localizable.strings, and that has worked, but after doing that, the project's targets also turned red in Xcode, and building the app doesn't change that fact. Very odd.. any idea what could be going on, or how to get this going?

Luke
  • 9,512
  • 15
  • 82
  • 146

1 Answers1

4

This can be a real pain. I even had XCode crash on me when trying to correct unwanted file locations. I found that the best way is to create the localized file (be it .strings or .xib) as a copy of the source language version outside of XCode, then drag and drop it into XCode. If you do this then XCode will display it correctly and your targets' Build Phases > Copy Bundle Resources settings will include it with its correct location. I don't know why your targets are displayed in red, perhaps you could look under Copy Bundle Resources in case anything is wrong there, or also select your project and click Validate Settings in case you haven't already done so.

Also, if you have been testing in the simulator beware of how XCode does not clean up the files in your app bundle--you may want to delete the app and run it again to make sure it's working with your new location.

Community
  • 1
  • 1
Clafou
  • 15,250
  • 7
  • 58
  • 89
  • Where do you drop the localized file in Xcode such that it knows which lproj directory to put it in? – JLundell Jul 31 '13 at 16:02
  • What I've used successfully is to save the files in your relevant lproj directory on disk, and then drag them into your XCode Project Navigator pane, just below the matching file in the existing language (or languages). XCode will happily add it to the language group of that file. – Clafou Aug 01 '13 at 19:56