Search code examples
iosxcodeswiftlocalizationlocalizable.strings

NSLocalizedString() picking up cached entry from before Localizable.strings is localized


I am building my first IOS iphone 6 app.

I am having problem getting Xcode to pick up key/value pairs from the localized version of Localizable.strings. The NSLocalizedString() method seems to be returning cache entries from before I localized the Localizable.strings file.

  1. You can see in the screenshot below that when I only had only one Localizable.strings file, the code picks up the key/value pair I was looking for just fine https://www.evernote.com/l/AAIi1y9qYi5H9o_SiUduTECZJZMvYr5FCfw
  2. When I tried localizing the Localizable.strings file (i.e. having Base, English, Chinese version of the file), NSLocalizedString() returns the key value from when I had one Localizable.strings file. https://www.evernote.com/l/AALbxEQwnuVFHaHMLduAgZw5N1op8o2Alc8 I know this is happening because when I change the values for the same key across all three files, it's still returning the old value.

I've also tried

  1. Resetting the simulator settings (this suggests the cache is in the build)
  2. Restarting the simulator/Xcode
  3. Searching for the old value in my project, couldn't find the old values that NSLocalizedString is returning
  4. Changing the key to something else altogether, NSLocalizedString just returns the key in this case
  5. Recreating Localizable.strings file and localizing it again using File Inspector, same thing happens consistently each time

I am really running out of ideas. I am using Xcode: Version 6.3.1 (6D1002), any help would be much appreciated :)


Solution

  • Turned out I had to clean the build. Go to Product -> Clean in xcode.