I wanna set another language as default when the app starts for the first time. iOS doesn't not have this language as an interface language, so my only way is to set it manually. I've found dozens of solutions on SO, and those that work, ONLY work in simulator and not on a real device. Here's what I've tried:
First of all, the way to set the app's language is:
UserDefaults.standard.set(["xx-XX", "yy-YY"], forKey: "AppleLanguages")
The thing is, that this needs the app to be restarted, while I want it to be set the first time the app starts. I've also tried:
UserDefaults.standard.register(defaults: ["AppleLanguages": ["xx-XX", "yy-YY"]])
and even calling UserDefaults.standard.synchronize()
which in most cases is not needed at all.
And the places I've tried putting this code:
- application(:didFinishLaunchingWithOptions:)
- application init :|
- Subclassing
UIApplication
, creatingmain.swift
and adding the above codes as top level statements
And in info.plist
:
- Setting
Localization native development region
toxx-XX
- Setting the first element of
Localizations
toxx-XX
By the way, implementing custom localization is not an option at this point in time.
And what confuses me the most, is why such a feature works in simulator and not a real device.
EDIT:
I even deleted the default english language, and adding English (World)
again, so that there was no Development Language
label beside it. Still didn't work.