Bill
Bill

Reputation: 3823

Why has Xcode 6.1 killed [NSLocale preferredLanguages] in IOS 8 simulators

Yesterday Xcode updated to v6.1.

Now, [NSLocale preferredLanguages] is returning an empty array in the iPhone, but only for IOS 8 - both in iPhone 5 and 6 emulators. IOS 7 simulators are still working fine.

A physical iPhone 6 device doesn't appear to be affected - it's just the simulators.

The usual attempts - clean project, restart Xcode, reboot Mac - have made no difference. So, what's the best strategy - wait for Xcode 6.1.1, or send a complaint to an Apple list (which one) ?

Upvotes: 4

Views: 2975

Answers (4)

Tomino
Tomino

Reputation: 6269

Setting Product -> Scheme -> Preferences... didn't helped me, so I made a simple workaround:

NSString *language = [[NSLocale preferredLanguages] count] > 0 ? 
    [[NSLocale preferredLanguages] objectAtIndex:0] : 
    @"en";

Upvotes: 0

malex
malex

Reputation: 10096

You can use category with currentLocale method swizzling as described in here. The category allows one to override in general language and region settings in the project for all targets at once.

Also you can use scheme settings for each target in separate way. If you have many localizations in your app,

enter image description here

you can change Application language and Application region in scheme settings for each target. You can even make a separate target for each localization for faster language tests.

Product -> Scheme -> Edit scheme...

enter image description here

Upvotes: 7

Jeremy Huddleston Sequoia
Jeremy Huddleston Sequoia

Reputation: 23651

I've flagged this for consideration as a dupe. Global preferences aren't working in the iOS 8.1 simulator. Localization is one such global preference. See:

See iOS8.1 Simulator always uses US keyboard layout despite german hardware keyboard

As for "strategy" ... you could just note that it's a known issue documented in the release notes and wait for a fix, or you can file a radar at http://bugreport.apple.com

Upvotes: 0

Evan R
Evan R

Reputation: 875

First, they're simulators and not emulators. Second, I'm not seeing an empty array returned for [NSLocale preferredLanguages] under Xcode 6.1 (6A1052c) and any iOS 8.1 simulator, but I do always see "en" returned regardless of the language selected in the system settings. I do see correct behavior for any iOS 7 simulator, as you note.

I would file a bug complaint if one hasn't already been filed: more info at Changing language on iOS 8.1 simulator does not work.

Upvotes: 0

Related Questions