iOS 8.1 Simulator always uses US keyboard layout despite german hardware keyboard
This is a known issue with the iOS 8.1 simulator runtime and is mentioned in the Xcode 6.1 Release Notes:
Localization and Keyboard settings, including 3rd party keyboards, are not correctly honored by Safari, Maps, and developer apps in the iOS 8.1 Simulator. [NSLocale currentLocale] returns en_US and only the English and Emoji keyboards are available. (18418630, 18512161)
The same is true for other preferences that should affect all apps and not just the locale (eg: keyboard settings).
As mentioned in the iOS SDK 8.2 beta 2 Release Notes, this issue should be resolved in iOS 8.2:
Fixed in beta 2 Additional keyboards, including 3rd party keyboards, may not appear in Safari, Maps, or 3rd party apps in iOS Simulator
If you need to use iOS 8.1, you should be able to use the German layout in some apps but not others. For example, Safari and Maps are two examples of apps that it will not work with.
It's iOS 8.1 Simulator's bugs.
I could tested language by setting the "Application Language" in the used scheme.
Go to Product > Scheme > Edit Scheme... or press cmd + Y.
Source: Answer of Yoshihiro Sakamoto in Apple Dev Forum
Before Apple makes fix one can use the following checked solution based on NSLocale swizzling
.
In fact we only need to substitute wrong currentLocale
which is broken in iOS8.1 simulator.
Attach the category to projects and add it in .pch
file (don't forget to clear and rebuild project).
// NSLocale+ios8.h
// Created by Alexey Matveev on 01.11.2014.
// Copyright (c) 2014 Alexey Matveev. All rights reserved.
#if TARGET_IPHONE_SIMULATOR
// define here your locale identifier: de_DE, ru_RU, etc
#define LOCALE_IDENTIFIER @"de_DE"
@interface NSLocale (iOS8)
@end
#endif
// NSLocale+ios8.m
// Created by Alexey Matveev on 01.11.2014.
// Copyright (c) 2014 Alexey Matveev. All rights reserved.
#if TARGET_IPHONE_SIMULATOR
#import "NSLocale+ios8.h"
#import <objc/runtime.h>
@implementation NSLocale (iOS8)
+ (void)load
{
Method originalMethod = class_getClassMethod(self, @selector(currentLocale));
Method swizzledMethod = class_getClassMethod(self, @selector(swizzled_currentLocale));
method_exchangeImplementations(originalMethod, swizzledMethod);
}
+ (NSLocale*)swizzled_currentLocale
{
return [NSLocale localeWithLocaleIdentifier:LOCALE_IDENTIFIER];
}
@end
#endif
Hope now you see the same
One more thing, using this approach you get one pleasent side effect: keyboard chosen via category locale is always in use and doesn't depend on system settings and keyboards added. So simulator setting reset doesn't require to add your keyboard again.
The category approach allows one to override language and region settings for all targets at once without making change of these parameters in each target scheme separately.