In general
NSLocalizedString
works in framework code. The most obvious gotcha is that you have to pass in the right value for the
bundle
parameter. The standard approach for this is to call
+bundleForClass:
, so, in Swift:
NSBundle(forClass: self.dynamicType)
Are you sure you’re doing that correctly?
The other thing to watch out for is that the system tries to make sure that your app is consistently localised. So, if you have a framework contain English and German localisations, and you call it from an app that only contains an English localisation, the framework will use the English resources. If things didn’t work that way you run the risk of having half the app displaying English and the other half displaying German, which is clearly not good.
So, make sure that the app you’re using to test your framework is localised appropriately.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"