NSLocale preferredLanguages objectAtIndex:0 always return "en" - iphone

Simulator's language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0] always return "en"?
Neither preferred language nor region is related to "en", where does "en" come from?
Tried to get [[NSLocale preferredLanguages] objectAtIndex:2], then crash shows *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (2) beyond bounds (1)
Does it means there is no any languages are set in simulator? So weird!
This never happened before upgrading to Xcode 6.1 with iOS8.1/7.1.
Meanwhile, tried same thing on my iPhone 5, console output correct thing.
Why so weird? Does anybody have such problems?
Updates: 1
Delete Xcode as well as simulators, and reinstall it by downloading from Mac Store.
Create a new simple project, change simlulator's language
Still get always "en".
Oh! What's wrong....
Updates: 2
Today, reinstalled brand new Yosemite by reformatting HD
Download Xcode 6.1
Start a new simple default project
Put these codes
Change / Add language of simulator, Japanese, Dutch, English,
Run
Oh, God! Got only "en" again, Japanese and English not found!
Why still only one "en" could be found? Where are Japanese and English?
What happened to simulators?
Is there anything I missed?

This is a bug. It was driving me crazy.
Apple already knows it.
See this answers:
iOS8.1 Simulator always uses US keyboard layout despite german hardware keyboard
and this:
iOS 8.1 Simulator Localization broken (NSLocalizedString)
(In the answer there is a temporary fix changing the schema)
Best,
gigi

My iOS simulator suddenly started reporting "en" rather than "en-US", so it seems this issue is still active.
Reproduced in:
Xcode 8.2.1, iOS 10
Xcode 9.4.1, iOS 11
I went into the language settings and English and United States were selected. I selected Canada and French, and got "fr-CA". I then switched it back and started getting "en-US" again. I've been unable to reproduce the "en" issue since.
So it appears we cannot pass the values of [NSLocale preferredLanguages] on assuming they will be Language-Region pairs.

Related

Xcode ERROR ITMS-90022: Missing required icon file. The bundle does not contain app icon 120x120, 167x167, 152x152

I've been searching for a solution to this Xcode issue for hours! I realize there are a bunch of posts on stack overflow with the same issue, but most of them are outdated (Xcode 9 or earlier and from 2016/2017). Does anyone have a solution to this issue? I am running Xcode 11.4.1 and all of the AppIcon images are correctly set in the Assets.xcassets folder. The application runs fine when building to simulator/iPhone and it was uploading to AppStoreConnect with the same settings last version of my app (a few weeks ago).
Answer: Don't include special characters in your app's Display Name. I'm not sure how they're connected, but the Display Name on my application had ~ in the title and after changing from ~title~ to title the build uploaded and this error message went away. Hope this helps someone ~lol~
The error is confusing because the 120x120 reference doesn't clearly state that you need to fix the "60pt" app icon asset in a 2x format.
The iPad version of the error can be solved by turning off iPad as a platform choice. I think it might be good to do that as you troubleshoot.

dictionaryHasDefinitionForTerm issues in xcode 4.5

fourLetterWord = #"isdjfiodjof";
if ([UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:fourLetterWord]) {
self.display.text = fourLetterWord;
return;
}
else
fourLetterWord = #"";
This string is getting accepted. I do not know what I am doing wrong here, but before 4.5 this worked fine. Is this an issue with xcode 4.5, or is there something wrong with my code?
I just had the same issue and start working around it.[UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:fourLetterWord]) method doensn't work in the simulator for some reasons, Apple need to fix it.
BUT if you TEST YOUR APP IN THE DEVICE [UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:fourLetterWord]) method runs and gives you the right result.
it's kinda slow though.
hope helps.
dictionaryHasDefinitionForTerm: always returns YES if no dictionary has been downloaded yet (because if there is no dictionary, it can't know whether the word is in it).
The download is automatically offered when you actually show a dictionary popover in any app. I think the download-on-demand feature was introduced in iOS 6, along with dictionaries in languages other than English.
My experience is that this works fine on my iPad running iOS 5.1.1 but returns TRUE every time on my iPod running iOS 6.1.3. I've logged it as a bug with Apple.
Update: omz is right. Once I had downloaded Apple's dictionary onto my iOS6 iPod then it validates the word correctly. It was so long ago that I installed iOS5 on my iPad I had no memory of whether I'd installed it manually or if it was done for me. Regardless, it requires a manual install on iOS6 for this method to be of use.

iPhone localization stuck on russian

I am currently localizing an app for a client, we already had EFIGS in, and are now adding portugese and russian. Everything fine with the portugese, but as soon as I add ru.lproj to the project, the app will always run in russian no matter what the device language settings are ... anybody ever experienced this? any ideas? tips?

iPhone - Wrong Localization after Changing the Language

I am developing an application that supports English and Arabic localization. If the iPhone language is set to Arabic, everything is fine. If I changed the language to English, the app continues to change in Arabic.
I tried the following:
Terminating the application before changing the language.
Removing the application from iPhone. Changed Language to English. Restarting the iPhone. And building the application from scratch (still in Arabic!).
I tried cleaning using shift-command-k (also failed).
I removed the application. restarted the phone. Cleaned the build folder (shift-option-command-k). Then I built the application, and guess what, it's still in Arabic! (How, in God's name, did the iPhone know that I used Arabic before?! I restarted the phone many times!, removed and clean the build directory!).
So, what do you think I should do?
Note: other apps that provide localization are working fine.
Does the project have en.lproj Localizable.strings file?
Thanks #Shatou Dev ,I make my comment as an answer.

iPhone: App crashes on specific devices

Not long ago, I released an app to the app store. I tested it using both the simulator and my iPhone 3GS (unfortunately I don't yet have an iPhone 4) - very few, if any crashes happened even after frequent use.
-
What's wrong:
Some of the reviews suggest that it is crashing on iPhone 4 (possibly on startup) - I have also noticed this with several of my other apps, which don't have very many downloads.
I have no way of debugging these crashes - but what possible reasons may there be for frequent crashing on specific devices (possibly just iPhone 4 - not definite though - although I would think it is tested with iPhone 4 when being reviewed)? My app uses no out of the ordinary frameworks or API methods, and very little memory when running. Is it possible that these crashes are occurring on Jailbroken devices? No iTunes connect crash reports as of yet.
-
TLDR: App crashes on specific devices, can't replicate it. No ideas where to start - Help?
-
Also: If anyone's feeling particularly generous and wanted to confirm whether or not it works on iPhone 4, then you could try my app (it's free) - app store link - I'd be very grateful! Otherwise any reason that specific devices may crash the app would be great, or anyone that's had a similar experience - I just don't even know where to start when I can't replicate the bug.
Ok, I tracked down your problem: :-)
It's the region settings that make it crash - use Germany and it will crash, use US and it will be fine. So looks like parsing problem.
This is the most stupid thing that ever happened to me. Yes, part of the issue is because of location of the device, but this is not the main cause.
If you are using NSDateFormatter some where in your app, that's where it crashes. For example in my case it was because 24hr and 12hr systems. In US format the default time format is in 12hr system with am & pm.
In my code I was trying to access the am and pm part of the string that I was getting from [formatter stringFromDate:date] and on device with 24hr system there was no such thing to access. so it would crash the app.
It was happening in non-US countries that the default format of the NSDate is other than 24hr system.
Make sure you define the format of the NSDateFormatter before trying to access any part of it.