Xcode Localization is driving me nuts! Not loading Storyboard

Stéphane Schorderet picture Stéphane Schorderet · Oct 8, 2012 · Viewed 9.9k times · Source

It's been 2 days this issue is driving me nuts.

I'm trying to localize my iOS app but for the life of me I can't get it to work. It works easy enough when I try on a blank project but not on my current project.

I've added the languages in the Localizations using "+", I've localized the storyboard but when I check on simulator or device I still see the english version. And in fact it's not even the English one because if I change the Maintsoryboard (english) I don't see the changes in the device ... I still see the initial texts.

I've tried reseting the simulator, deleted the app, etc. No luck.

I've reverted to a backup tried adding everything again. No luck.

Can someone please help? I know it's not much to go on, but I don't know what to explain to help you help me. So please let me know if I'm missing some info.

FYI, when I look into the app's folder in Developer, I initially don't have a en.lproj when it seems I should have one by default?

Answer

Jon Hess picture Jon Hess · Oct 9, 2012

It looks like you already figured this out, but I think what probably happened is that originally you had "MainStoryboard.storyboard" as an unlocalized resource. This means that when you build your app, you get a "MainStoryboard.storyboardc" as an unlocalized resource. When you change your storyboard to be localized, you get a "Base.lproj/MainStoryboard.storyboardc" in your bundle resources.

There are several copies of your app when you're building in Xcode. There's the copy on your device or in the simulator, and there's also a copy in your derived data folder in Xcode. When you do an incremental build of your application, the copy in the derived data folder in Xcode is a merge of your new content and your old content. So, when you modify a resource in Xcode, and rebuild, you get the newest resource. However when you rename or delete resources, the old copy is still left in the build directory until you perform a clean operation.

This means that your build product probably had both "MainStoryboard.storyboardc" and "Base.lproj/MainStoryboard.storyboardc". When NSBundle loads resources, it prefers unlocalized content, and would load the old "MainStoryboard.storyboardc".