4

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) ?

Bill
  • 3,806
  • 5
  • 33
  • 45
  • possible duplicate of [iOS8.1 Simulator always uses US keyboard layout despite german hardware keyboard](http://stackoverflow.com/questions/26146668/ios8-1-simulator-always-uses-us-keyboard-layout-despite-german-hardware-keyboard) – Jeremy Huddleston Sequoia Oct 29 '14 at 01:54
  • Have same issue. One target in project receives preferredLanguages with 1 object, but another target of the same project receives an ampty preferredLanguages. iPhone Simulator IOS8 on 6.1.1 – poGUIst Feb 06 '15 at 11:30

4 Answers4

7

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

Community
  • 1
  • 1
malex
  • 9,874
  • 3
  • 56
  • 77
0

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.

Community
  • 1
  • 1
Evan R
  • 875
  • 13
  • 27
0

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

Community
  • 1
  • 1
Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • I filed a radar with Apple and got back a message saying they were already aware of it. My strategy is to use a default if the array comes back empty in the simulator, and wait for a fix. – Bill Nov 16 '14 at 06:46
0

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";
Tomino
  • 5,969
  • 6
  • 38
  • 50