Which file contains Localization info in an iPhone Xcode project? - iphone

I am working on a iPhone app and trying to add a German localization. And we are using TFS for version control.
I have added the German strings file all right, but every time I restart Xcode, the Localizable.strings(German) is gone. The file still exists on disk, but just not included in the project. I believe it's because some controlling file is read-only. I have to find this file and explicitly check it out. I cannot checkout/check-in the whole project because the guy integrate the code will be mad.

It's the xxxxx.xcodeproj folder.

Related

Loading wrong xib after updating the app

I already have my app on the App Store and I want to publish a new internationalized version. So, I created a xib for the english version and a xib for the french one (localized in the good en.lproj and fr.lproj folders). And when I set up the app on my iPhone that already have the first no-internationalized version, I had some troubles with the interface : the app does not update all the changes on the UI and I still have french labels even if I set the iPhone language to English (the app does not choose automatically the good xib).
If I only clean the project and build again, it still does not work but when I cleaned my project, deleted the app of the phone and build again, everything works like a charm. I don't want that the problem occurs to people who already have the app and update it via the App Store :/ is there a way to understand what happens ?
This is what happens: In your old version, you have one .xib file in the application bundle, and the bundle looks like this:
<bundle-path>/interface.xib
In the new version you have the two localized versions of this file and your bundle looks like this:
<bundle-path>/fr.lproj/interface.xib
<bundle-path>/en.lproj/interface.xib
When the app tries to load the xib file it looks directly in the bundle directory first and, if it doesn't find the file there, looks for the file in the subdirectories with the localized files.
If you have the old version on the device and then build and run the new version from Xcode, legacy files are not deleted, so you end up with this bundle
<bundle-path>/interface.xib
<bundle-path>/fr.lproj/interface.xib
<bundle-path>/en.lproj/interface.xib
and the app loads the unlocalized file as it never needs to look into the localization subdirectories.
I assume that legacy files are not deleted when you deploy from Xcode to a development device for performance reasons.
However, your users will not run into this problem. When a user installs an update of your app, the app bundle will be completely replaced by your new bundle. So if you upload a "clean" bundle without legacy files, and this version works when you do a fresh install on a your device, it will also work on your users' devices.

Experiencing An Issue With Localizable.strings in an iOS iPad App

This is the first time that I have attempted to add some localization into an app using Localizable.strings files and I am experiencing an unexpected issue with it. For clarity, these are the steps I have gone through.
File >> New >> New File and added a Resources file of Strings type.
Named the file 'Localizable.strings'
Clicked into the Localizable.strings file and added Spanish through the Localization section. (I have confirmed in my project folder that I have the en and es folders).
Started to add my KEYS in the Localizable.strings (English) file and then add the Spanish translation into the Spanish file.
As an example, this is one of the localizations I am trying to add.
"CAMERA_ERROR" = "The device does not have a camera";
I am added the exact same string in the Spanish .strings file, but changing the text to suit Spanish. Within my app code I am using the following:
NSString *cameraError = NSLocalizedString(#"CAMERA_ERROR", nil);
Everything seems fine up until this point, but this is where it gets weird and I get confused. If I run the app on one of my iMacs it works fine and depending on what language I set the simulator to it displays the correct English or Spanish string.
However, when I run the exact same app on this MacBook Pro it doesn't display the string, it instead takes the "KEY" title and displays that. So instead of showing the message as "The device does not have a camera" it shows it as "CAMERA_ERROR". The code is exactly the same as it is the same project cloned from a git repo.
Can anyone shed any light on this? Any setting on the MacBook that could be different?
Try doing the following on your MacBook Pro:
clean the project;
remove the app from the simulator/device;
rebuild the app.
This should fix it.

debug version of iphone app running under simulator -- programmatically locate own project file?

I am working on an app whose debug version will be used on the simulator by different people, including some who will edit metadata that control the appearance of the app. I want to have a mechanism for editing and reloading said metadata without rebuilding the app. To do that, the app will need to find the plist file in question. Not the version of the plist that is inside the iphone simulator. Rather, it needs to find the version that is used to build the app. Rather than asking users to point out where the file in question is located, can the app determine that information programmatically?
Finding the project file would be good enough, because the plist will always be in the same location relative to the project file.
In Xcode you can add your own field to info plist and use ${SRCROOT} as value Xcode will automatically change it to path of your current sources path on build. Then you can obtain it from your application.

Adding localizable files to project on Xcode 4

I'm developing an App that needs Localization.
I've followed these steps:
I've created the es.lproj, it.lproj, en.lproj folders in the root of the project with finder.
I've created the Localizable.strings file in each folder with the key pair values corresponding to the target language.
I've imported with Add Files To option from Xcode.
When I test the App in the iphone simulator all works fine. I configure the iphone to any localizaed language and the app is translated properly.
But when I run the App in the device, only shows the strings in english.
I've made a test following these steps.
From Xcode 4 right button over Supporting Files Folder, New File.
Create Localizable.strings file
In file inspector, section Localization. I've added the rest of languages. Creating the file like a folder with all Localizable files in the tree.
In the root folder of the project, the xcode created a folder for each language.
After editing every file, I've executed in simulator and all works fine. I've tested in 3 different devices and the only language is English.
In the Project -> Info -> localization I've added every language.
In the Build Phases I've observed that only is referenced the Localizable.string file in the en.lproj folder. I've tried to add the rest of files, but only accepts one more Localizable file. I've tested in device with the "extra" added language but doesn't works.
Can someone help me please?
Thanks in advance.
Try this: Remove the app from the device, clean project, make sure that the files appear in Build Phases>Copy Bundle Resources and run again.
Are you sure you are testing properly on your device ? I just tried making a simple localization test, just a Hello world in different languages, and when i
I used Xcode 4 and followed the same steps as you. Changed my device language, reloaded the app, and there it was.
You might need to do a clean install in order for this to work. Do the clean install after you changed your device language to "something you haven't seen yet" ;]
Maybe this tutorial can help you : Localization Tutorial with XCode
Have you tried to delete the app from the device and then reinstalling?
EDIT: I have checked in a project of mine and the names I see are: English.lproj, French.lproj, etc.
Don't know if this could make a difference, but you could try it. Also, you can go to the app binary for the iPhone with the Finder and select Show package content to inspect its content and make sure the localization files are there This could help to pin down the problem...
If it can be run in the simulator ok, but the device has a problem with the localization, then the link provided here by Nils Munch has the answer. In troubleshooting it says "Unlike the iPhone simulator, the iPhone only recognizes strings files that are formatted UTF-16. Always test your localizations on the device, as the simulator and the device do not always behave the same way."
I think the problem here might be the file is UTF-8. The simulator can handle that but the device can't.

Why does my XCode project include the wrong icon file for my iOS Application?

I am creating a lite version of my app, and used Chris Fletcher's blog here as a guide to setting up an Xcode project for multiple apps. I have everything working great except for the icon file.
Here is an overview of what I have:
2 info.plist files (One for each version of the application)
In my paid info.plist, I reference the icon "IconPaid" for the Icon entry. In my Xcode project, I have added IconPaid.png and IconPaid#2x.png.
In my lite info.pist, I reference the icon "IconFree" for the Icon entry. In my Xcode project, I have added IconFree.png and IconFree#2x.png.
When I go to build both apps, my lite app shows up with the paid icon. I took a look at the package contents of my lite app, and sure enough the IconPaid files were included but not the IconFree files. I took it a step further, and printed out the value for the CFBundleIconFile in my app, and it correctly shows up as "IconFree".
So my question - Where else is the icon file referenced in a Xcode project besides the plist file? I thought that was the only place...
It sounds like your free target is copying the paid version of the icon instead of the free version. Look under Targets/Project-Name/Copy Bundle Resources and check that the free version is copying the correct icon file.
I'm not sure why the IconPaid.png is showing in the free app (assuming your build settings of your free target are referencing the proper info.plist). You may want to clean all targets and delete your intermediate build files too, and delete the old version from your simulator or device.