Xcode 5/iOS 7 - localization not working in simulator - ios

I was following one of Ray Wenderlich's tutorials on localization but I can't seem to get it working.
I've set my project up for localization in English and French and I have a locaziable.strings file for each:
The French file has the correct (well as far as Google translate goes) French versions of my string:
I'm setting the strings by calling the correct key from the localizable.strings file:
NSString* strTitle = [NSString stringWithFormat:NSLocalizedString(#"Title", Nil)];
And I have the simulator set to French (BTW: Whenever I do a language change the simulator crashes).
But it is not pulling from the correct localizable.strings file. It's still displaying in English:
Am I doing something wrong?

If you are using xcode 6.1.1 and iOS sdk 8.1,try this workaround.
It seems localization does not work with xCode 6.1 and 8.1 simulator.
Workaround:
Go to "edit schemes" >> "Run" (side bar) >> "Options" tab >> "Application Language"
Select the language you wish to run the app on the simulator.
I got this workaround from Workaround by natanavra
Thanks to him.
However I read on developer forum,that it is working in 6.2 beta version of Xcode. Hope it do.

Maybe you have run the app at some time where the file Localizable.strings already existed but has not been localized yet. If this is the case, this unlocalized file still resides in the resources folder in the application bundle in the simulator (when you build an run a new version of your app in the simulator or in the device, unused files will not be deleted). This can lead to problems.
Try to delete the app completely from the simulator and build an run again.

I have experienced similar issues (IB localization in my case) on device. So general answer would be
Device - Uninstall app and clean project by Shift+CMD+K
Simulator - Go iOS simulator > Reset Content and Settings and clean project by Shift+CMD+K
These problems are really annoying. Along with poor ability to update localized strings is localization one of the biggest drawback of iOS development.

Another problem that could cause localization not work is the encoding of the strings file. Localizable.strings's encoding must be UTF-16. The default encoding of text file in xcode is UTF-8, that cause me spending a whole day to check why the localization not work.

In Xcode 6.0 and later, Localization not work by changing language in Simulator not working.
You have to edit scheme before running your application.
Go to Edit Scheme -> Run -> Options, change language here.
Now, Run Your Application. It will Work.
For more details, check this answer : Changing language on iOS 8.1 simulator does not work

My problem for this was an incorrectly encoded character in the localization file.

Related

Can I change the Apple Watch simulator language?

Is it possible to change the Apple Watch simulator locale? I want to test the localization of my watch app. I can change language on an iPhone simulator, but the watch simulator is always in English. I can't find any language settings:
Most certainly not possible neither via Watch Simulator UI nor iOS Simulator Watch app, but you can copy over values from iOS Simulator folder located in:
<simulator_dev_folder>/data/Library/Preferences/.GlobalPreferences.plist
to the same file in your Watch Simulator.
Plist keys to look for:
AppleLocale
AppleLanguages
AppleKeyboards
You cannot change the Apple Watch simulator locale, but you can change the locale of your Watch App. I use this to test localization. To change your app locale, go edit the Watch App Scheme: Run->Options->Application Language - choose the language and re-run your Apple watch app.
Run|Options|Application Language
Unfortunately it works only on Xcode 7.2, not on Xcode 7.1. There is no other known possibility.
EDIT
There is a brand new library for language and locale automate testing. It's called AutoMate. The documentation can be found here.
I post my comment for a more readable format.
Hope that can be a "viable" work around
Create the different localization files: English, French, Spanish, Chinese…
localize all elements here
then, open the English files
copy the content of the language you want to test after the present english text (that will supersede it).
To come back to english, delete this added foreign text.
I tested, it works.
I just get an error log, without apparent consequence
Watch Extension[3520:334638] [default] -[SPRemoteInterface _interfaceControllerClientIDForControllerID:]:2140: ComF: clientIdentifier for interfaceControllerID:DC00003 not found
But that is good enough to test localization on simulator.
Removing the extra text clears the error.
I improved this answer.
https://stackoverflow.com/a/54883097/2519218
Change directory to your simulator devices. eg. /Users/$USER_NAME/Library/Developer/CoreSimulator/Devices
Detect your watch simulator. I used ls -trl command after build. eg. 046D5EDA-1808-4BE2-A16E-04DF0324B032
plutil -convert xml1 ./046D5EDA-1808-4BE2-A16E-04DF0324B032/data/Library/Preferences/.GlobalPreferences.plist -o change_global.plist
Edit change_global.plist AppLanguages's section you want to use by vim. I wanted to use ja, so it's like <key>AppleLanguages</key> <array> <string>ja</string> </array>.
Put change_global.plist to ./046D5EDA-1808-4BE2-A16E-04DF0324B032/data/Library/Preferences/.GlobalPreferences.plist. like cp change_global.plist ./046D5EDA-1808-4BE2-A16E-04DF0324B032/data/Library/Preferences/.GlobalPreferences.plist .
Restart simulator.
Unfortunately, it doesn't seem like you can change the language in the watch simulator at this time. On the device, it's located in the iPhone Watch app under General -> Language & Region. However, on the iPhone simulator, there isn't even an option for the General section. This is all that shows up under the Watch app:

Localisation issues with localisation strings

Just spend another evening, trying to figure that out.
Here is what I am doing:
1) Creating a clean project with tabbed iOS application in XCode 6.3.1;
2) Under Project/Info/Localisations I am adding another localisation (Russian,German, doesn't matter)
3) In Main.strings file, changing corresponding strings, OR doing exactly the same by Exporting/Importing .xliff file.
4) Deleting app from simulator/device, cleaning project from Product/Clean, deleting derived app data from corresponding folder
5) Changing language in simulator/device
6) Making a run... Still English. Localised strings just wont pick up, no matter what.(even though they are looks just fine trough assistant editor)
What am I doing wrong? Is that suppose to be that complicated?
Try running on a device. Xcode 6.x had known issues with the Simulator not showing localizations.
Just got update from 6.3.1 to 7.0.1 XCode and the issue is fixed for me.
I am making exactly same steps and got Russian/German/English interface depending on the language I chose in simulator settings.
Guess that is it.

iPad apps never install in Retina simulator

I've racked my brains over this one, and I'm probably just making a stupid mistake. After switching to Xcode 4.5.1 (it may have happened at 4.5) I simply cannot load an app into the iPad Retina simulator. I've edited the compilation scheme to say to always use the Retina display for the iPad. No love. It used to be that you could change simulators on the fly and whatever one was open would be the one the project compiled for. But I can't figure out how to do this in 4.5. Help!
Something funky is going on, which seems to be not acting as expected. Try these solutions in the following order.
Your method is correct, you set your Simulator Display preference when editing your schemes. Make sure your destination for the scheme is the iPad simulator, that it's tied to the Run scheme, and set iPad Simulator display to Retina. Save/apply your scheme changes, try to run your app. If that doesn't work, close + re-open Xcode, check scheme settings to see if they stuck, and try again
You may want to double check if your changes stuck. Delve into your project file (by right clicking on your project file, and selecting "Show Package Contents"). Then navigate to:
xcuserdata->username.xcuserdatad->xcschemes->ProjectName.xcscheme
Open it up in your favourite editor, and check to see if there's a:
simulatorIPadDisplay = "2.000000"
...for your required scheme
If none of that worked, then it may be an issue with your derived data (unlikely, but step 1 should have worked). Go to Organizer, and select the Projects tab. Then hit 'Delete...' for derived data. Do the same as before; run, close Xcode, check and re-run.
Well we really are in a pickle, that is the only method to set your preferred simulator display for a build scheme. You may need to resort to removing Xcode and re-installing, and trying the previous steps again.
What on earth is going on?! We've exhausted our methods, you may need to let Apple know about this issue.
Well, after a long session of "find all of my settings files and save them, delete Xcode and all of its settings files, reinstall Xcode, re-download simulators and dockets, replace settings files, etc., etc." I found myself in the same position. No Retina simulator for me.
The problem wasn't Xcode or the project file--the 5.0 simulator will simply not launch in Retina mode. The 5.1 and 6.0 simulators work fine, as I discovered when I switched to them in the compilation scheme. Switch back to 5.0 and I'm stuck in normal simulator mode. The reason I've been using the 5.0 simulator was to test lowest-common-denominator iOS features. That, and there is a bug in iOS 6.0 that affects large packet transfer via IPSec that hasn't been fixed yet.
So, I still don't know what the missing Derived Data status was all about, except that it's fixed now and I assume that reinstalling the app was the fix.

Xcode suddenly stopped running project on hardware: "Could not launch xxx.app: .. No such file.." [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Xcode has stopped being able to run my app, it started directly after I deleted it from the device and attempted to re-install by rerunning it in Xcode (something I've done hundreds of times before).
It says
"Could not launch XXX.app"
"No such file or directory (/Users/Mylaptop/Library/Developer/Xcode/DerivedData/MyApp-ekxcbebfpzkahtfkujyqkcwprzia/Build/Products/Debug-iphoneos/MyApps.app/MyApp)."
I've rebooted the phone, relaunched Xcode, cleaned everything, rebuilt everything. This error message won't go away.
This is with Xcode 4.5 which I've been using since it became available, if I revert to 4.3.2 then Xcode says "Finished running app" but it doesn't actually do anything - the app is neither installed nor run.
I'm completely stuck - unable to run anything on the device anymore.
Any suggestions?
That is really annoying. This error happens in a number of different situations. Sometimes restarting the Xcode, fixes the problem. If not, follow these steps:
Disconnect your device.
Delete the app from your device.
Quit Xcode (Do not just simply close the window, quit it)
Delete derived data folder (~/Library/Developer/Xcode/DerivedData/-gbrvhlvwmpiobxdujegtghggrffp - or something like that)
Now start Xcode once again, connect device and run the project. It should work fine.
from DhilipSiva blog
Try deleting "Required device capabilities" in the -Info.plist file.
You can't require armv7 on a 3G, and you can't require armv6 on any newer device, so just delete this attribute entirely.
I found the answer. The iOS deployment target's version was not the same as my device's OS version.
First tried some of the above with info.plists and deleting derived data, clean, etc.
My solution: quit XCode, reopen project. Go to derived data in Finder. Deleted data for all projects (was all trashable, but I would try deleting your troubled projectdata first). And then it worked again. Deleting derived data from XCode didn't work.
The following resolved my problem... my app worked for me in debug/release, then I built a few ad-hoc archives and debug/release builds stopped working.
Symptoms:
invalid entitlements errors when launching from Xcode to device (play with entitlements...)
immediate abort with no error (finished running ) when running simulator
could not launch ... directory blabla.../build/product/debug-iphoneos/... not found when launching from Xcode to device.
Eventually after trying to benefit from everyone else's pain I found in Targets [AppName]:
Build Settings
Build Locations
Build Products Path build
should be
Build Products Path build/Products
No idea how this got set incorrectly.
This must be hard-coded somewhere in Xcode/Springboard because 'Products' appears in both Xcode and in the Device console.
This is Xcode 4.5.1.
I solved this problem by
renaming a directory above my XCode project
Changing the name of the project in XCode fixed it for me.
In XCode, under the Project Navigator, click the project name, and it should let you rename it just like a file in Finder. Deleting derived data did not help.
I built my XCode Project with CMake and somehow it (or my stupid self) deleted or emptied the property "Executable file" in the info.plist. I set it back to ${EXECUTABLE_NAME} and it worked again.
Took me really alot of time working through all the suggestions and fixes until I finally found that problem.
Hope this will help some one struggling with the same problem
Edit:
It was in some way CMake messing up my plist file. I created my own Info.plist and used it the following way:
SET_TARGET_PROPERTIES( MyApp PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/MyApp.plist )
Inside my plist I had this entry:
<key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string>
Unfortunately CMake still seems to parse that file and replaced ${EXECUTABLE_NAME} with an empty string since its the CMake variable syntax. My quick work around is the following:
SET( EXECUTABLE_NAME "\${EXECUTABLE_NAME}" )
Now it works like a charm.
I am probably alone with exactly this problem, but who knows.
I had the same problem, but in my case I had a wrong requirement in my info.plist (require gyroscope for an iPhone 3Gs)
I tried to run my project on a different system other than that on which it was developed. I was getting “Could not launch xxx.app: .. No such file..”.
Removed the app from the device and then deleted the derived data from organizer in xcode for the app.
Organizer-->Projects-->Derived DAta-->Delete
My problem was resolved.
You need to set the deployment target LOWER than your device's version
For me, the solution was just to use the correct (non-distribution) provisioning profile.
I was defaulting to always using my ad hoc provisioning profile, but then I changed to using my developer profile (team profile) and that solved things. I went ahead and cleaned out the Derived Data directory to be safe but I don't know for certain if it is required.
XCode used to have a warning that told you to use the correct provisioning profile but that error message seems to have gone away in XCode 4.5.
I've had this problem by a very strange solution.
My problem was slightly different as I have 2 Developer certificates in Keychain. We have two developer accounts (lets say AD and BD).
1) I did change Bundle identifier from com.BD.game to com.AD.game
2) Device on which I had problems was only signed in AD provisioning profiles.
3) I was unable to debug the game on iPad - although the device had valid provisioning profiles, I had valid certificates, I restarted Mac, device, reinstalled Xcode ... nothing helped.
Do what i did today was examining the project.pbxproj file for any strange entries.
What I found was that Xcode was using proper provisioning profile, but signed the ipa/app with wrong certificate.
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: **BD** (XX******)";
After I manualy corrected the name and id; everything works like charm.
I got the same error. In my case I was set deployment target as 6.1 and trying to run an iOS 5.1 iPad. When I changed my deployment target to 4.3, issue solved.
Still having the problem . Try this
Disconnect your device.
Delete the app from your device.
Quit xcode.
Now start Xcode, connect device and run the project. It should work fine.
For me (using IOS 7 and Xcode 5), the error went away right after I did "Add to Member Center" with my device in the Organizer.
I would like to mention that the easiest way to open the DerivedData folder in Finder is the following:
Open the Organizer.
Click on "Projects".
Select your problematic project.
Next to the path of the DerivedData, click on the little right-arrow button.
Deleting the contents of the DerivedData folder worked for me. Instead of using the "Delete..." button, you should have more success deleting the files manually through Finder.
Go to: your project Target - > Info and from CustoM iOS Target Properties remove the Required Device Capabilities.
In my case that were armv7 and armv7s.
After that the app was built successfully on my iPhone 4.
This is how it looks after i removed both of requirements
For me, I forgot that I had "telephony" in the "Required device capabilities" in the info.plist. Removed that, and it finally worked on my iPad.
For me restarting of Xcode, cleaning DerivedData and restaring device wasn't enough in most cases, until I had figured out that iTunes was also running, and after quitting iTunes everything worked fine!
So my steps now are simple:
1. Quit Xcode.
2. If iTunes is running, quit iTunes.
3. Reopen project.
No need to remove app from the device, clean project or restart/disconnect device.
I think that's because Xcode and iTunes use some common libraries (as you know, Xcode Installer always asks to quit iTunes on installing iOS SDK).
I had this problem and tried a number of the suggestions which didn't work for me - then I found the one about removing the "Required device capabilities" in the -Info.plist file (which for me included location-services & gps)
That worked!
I then re-added them and it still worked.. go figure.
This was xCode 4.6.1 & my app is developer with Phonegap/Cordova
I tried all the above and yet it still wouldn't run. I fixed the problem by changing the derived build location. File>Project settings>"derived data location" change to project-relative. Or you could just make sure the default path has permission to read/write.
My issue seemed to be picking picking Portrait (top home button) as Item 0 in Supported Interface orientations in my plist. Removing that or moving it down seemed to fix my problem. Go figure.
I had this problem too for a Universal app with Xcode 4.5 on my iPhone ONLY, where I had two debug devices:
iPhone 4 iOS 5.1.1
iPad 1 iOS 5.1.1
The Info.plist had an empty entry under "Required device capabilities"
I know that I did not enter this empty 'Item 0'. The app loads on the iPhone
since I removed the empty item. I did not encounter
this problem on any of several earlier versions of Xcode,
This means that Xcode 4.5 handles this 'inserted' item differently
for the two devices I use. I have been wrong before, but this does seem
like a bug in Xcode 4.5.
This may seem obvious but you must also set your deployment target to the operating system that your device is running.
So if you upgrade to iOS 6, it will set your deployment target to iOS 6. You'll need to deploy to 5.1 if the device you are testing on still runs 5.1.
My issue finally got resolved by checking to make sure that the productName attribute in the /* Begin PBXNativeTarget section */ section of my project.pbxproj file matched the name attribute.
Once editing it so that they were the same, Xcode finally runs the app on my device correctly!
Thanks to Max Weisel for helping me! :D
Deleting the derived data folder did not help for me.
Using Xcode 4.4.2 the only solution was to open Organizer and delete old expired and extraneous provisioning profiles on the iDevice. Then everything worked perfectly again.
This may be a red herring, but I experienced these problems when I added custom launch images before deleting the default ones. Deleting the default launch and custom images and then adding back in the custom ones fixed it for me. I'm working with iOS 6 and Xcode 4.5.2
There seems to be a few different things that can cause this very helpful error message.
For me, it was down to an incorrect "Required device capabilities" in the Info.plist. I had added a blank array item by mistake (on top of the the architecture, armv7).
Deleted the blank array item and now everything is fine!
I had this problem and nothing really helped except:
My problem started after changing the contents of my info.plist and no reverting had helped.
What solved it for me was:
Create a vanilla info.plist in a brand new project
replace the old info.plist with the new
renaming it (like app_info.plist)
Set Build Settings/Packaging/INFOPLIST_FILE to be the new one.
Make all the changes you need for your project
Hope that helps. I tried everything else suggested here and this was the only solution for me.
Facing same problem but now problem is solved, i deleted Executable file info.plist. I set it back to ${EXECUTABLE_NAME} and it worked again.. :)
In my case i just set 777 permission directly to xxx.app folder to all files and work!

Problems in changing language of my iPhone app

Hi I've created my iPhone app for IOS 5.0 with Xcode 4.2. By default it is localized in English.
I would like to make the app appear on the app store with language "French".
From my understanding, I've to remove English language and add the French one, but this is causing some problems to me.
At first, each time I open my app in Xcode, english language is added by default, even if I have removed it previously.
Moreover, if I localize my Storyboard files in French, the file is moved to my fr folder in project, but this causes in "Copy Bundle Resources" a problem with the file that becomes red.
To make it work again, I've to remove the localization from the Storyboard files.
Can you please help me?

Resources