xCode Localization - where to put .lproj files? - ios

I've looked for similar questions, but this must have been asked before. Either way, please point me in the right direction.
I've localized an app for the first time. It seems to work ok, but I have two sets of .lproj files. One set is in the settings bundle, and the other is in the main project directory.
It also appears that some settings are affected by one .lproj file content and other settings are affected by the other.
Should I leave "well enough" alone? Should I combine somehow? If so, where is the correct place?
If I find this has already been answered, please forgive. I will either delete this question, or point it to the existing response.
Thanks

That is really OK to have lproj's all over the project. What is more important - to keep translated files inside of Xcode file tree. You can easily localize your nibs and any other files just by selecting file you need to localize and by adding File localization in File Inspector.

Related

What does it mean when .xcodeproj files are shown in red in Xcode?

What does it mean when Library files are shown in red, as in the screenshot below? Does it mean these files have been added, but there's something missing from them?
This means that the reference to those two files has been lost. Someone moved or deleted them behind Xcode's back, and it no longer knows where they are.
As matt said earlier, this is because the project (notably the project.pbxproj file) has a reference to these files/subprojects, but they’re not found in the location in question. This can happen if you deleted them, renamed them, or you cloned some repo where someone forgot to add these to source control even though they’re supposed to be. It’s hard to say what happened without more information, but Xcode merely is telling you that files are not where the main project.pbxproj file is expecting them to be.
this happens when location mismatches or actual file is not there . search for these files in your mac , if is there , click on info and find the location . And if it differs , drag the file to app's necessary folder and in the pop up select copy

Some files are located outside of "MyApp" directory in my iOS app - why?

I'm now developing my first iOS app, and I found that two of my classes (hence, four files) are located outside of my MyApp/.
So in my filesystem, here's the current situation:
My App
- ClassA.h
- ClassA.m
- ClassB.h
- ClassB.m
MyApp/
MyApp.xcodeproj/
MyAppTests/
Other than the two classes, all of my class files are located in MyApp subdirectory. The other resources, such as Core Data model file or images are saved in the same directory.
However, why are the two classes, and only the two classes, located in the outside of MyApp subdirectory? When I move those files to the supposedly correct location, those files are no more "valid" in Xcode with the color of the file name is converted to red.
So here's my question:
Why are those two files located there?
Do they have any issues if they remain to be located there?
Should I fix this issue and save it correctly? I think I haven't had any issues so far with the Simulator and the actual iPhone...
I use iOS 7 and Xcode 5.
•Why are those two files located there?
A: When you have created these files or imported from external directory, you may have not taken care of the group/folder these files are getting created/imported into. Hence they are inside the main app folder in the file system.
•Do they have any issues if they remain to be located there?
A: No, this is certainly not an issue in the correct functioning of your app, but it is always good to manage your files under groups/folders for better file structure and it is easier to find files when they become large in number.
•Should I fix this issue and save it correctly? I think I haven't had any issues so far with the Simulator and the actual iPhone...
A : This depends on you. If you like to keep your files in folders and like everythin arranged in some pattern, then yes you can divide the app into different folders. When you move the files in a folder, the reference of those in XCODE should change as well, and thats why you see those files in red in XCode. No worries. Just delete the files and add them again. Make sure you uncheck the option "Copy files under detsination group's folder".
Now, you may seem the option of creating New Groups inside XCode. But it is good to be aware that these groups do not create separate folders inside file system. These are just for Xcode refernce. So, a neat way is to create folders outside of XCode, and then import these folders(can be empty) in Xcode. Now when you add any file in these imported folders, even from XCode, it will go inside the correct folder in file system.
I am sorry I am not on my MAC right now, so cannot paste actual images, showing how to do it. Feel free to comment, if I have instead of solving the issue, have rather confused you more:D
You can put your source files wherever you want, as long as Xcode knows where to find them. You can leave them here, or organize it in another way, as you seem to be willing to do.
So, if you want to move these files in your Myapp/ subfolder, just move them there, and when Xcode complains it can't find them, highlight all those files in red in the navigator, and in the "File inspector" pane (right hand side of the window), click on the little Folder icon to browse to the new location. If you selected all files you don't need to do that 4 times, Xcode will find it out by itself.

Loading a different plist depending on the target

I thought it would be interesting to attempt building multiple apps using the same code base, where the only differentiating data is held in a few plists. For example, one plist holds some theme info - a few key/values to drive the color scheme used in the app. I'll call the original version of this theme.plist.
I soon learned that I should create multiple targets in my project, and have been able to add these successfully. Each one, via it's own appname-info.plist, has a different name and bundle id - it's neat seeing all three on my home screen without any real extra work.
But right now they are all identical. I haven't figured out how to use a different set of data for each one.
My first thought was to have some folder for each target - each with its own theme plist named theme.plist - and somehow distribute each target with a different folder. But researching that idea doesn't get me much google juice.
So what about multiple theme files? Ok, so far that looks better - I can create an app1-theme.plist and 'app2-theme.plist' with different values for the same keys in each. And Xcode even lets me use some flags to say which targets should include each resource.
But I don't know how to load the appropriate plist at runtime. I need to examine something (the bundle ID?) and then assign the appropriate name of the theme plist to something (what)?
It seems like this might have something to with #ifdef, whatever that might be...?
Can someone explain how I should be looking to accomplish this? Am I on the right track? I'm happy to put some reading time in but I don't even know what to look up yet.
You are just about there. Xcode supports having multiple files with the same name in a project, one way you can do this by storing them in different folders within your project folder.
Unfortunately at this point Xcode won't give you a lot of help, so open your project in the Finder, create one subfolder for each of your apps, in those folders place a copy of the plist. Now add each copy in turn to your project, making sure you add each to just one of your targets.
You might want to create a group in Xcode called, say, "Theme files", to keep them altogether.
HTH
What you are trying to do is trivial. If you select a file from your project, and bring up the "File Inspector" in the utilities area (Press Command option 1) you should see a section "Target membership". Each target in your project will be listed, with a checkbox next to it. If you check the checkbox for a file and target, that file is built into that target. Un-check the checkbox for a file and target and that file is not copied over to the specified target (you may need to run a clean, and delete the app from the target device, to get rid of files that used to be included but that you have un-checked. Xcode generally won't automatically remove things that used to be included.
You could create a directory in your bundle and teach your app to scan that directory for plist files. Then include a different set of files in that directory for each target and each target app's behavior will change.

Xcode removing language specific storyboards iOS

A while ago i decided to make my application multilanguage. I ended up using localizable.strings. So a different file for each language with all the translations in it.
In my main storyboard i just use NSLocalizedString(#"example", nil); on all my elements etc.
The problem i have is that i just found out that i somehow ended up with a storyboard for each language. I can fold out my MainStoryboard_iPhone.storyboard and under this it lists the language specific storyboards (MainStoryboard_iPhone.storyboard (English) and MainStoryboard_iPhone.storyboard (Dutch). Since i do not use this because i do everything with the localizable.strings i do not need this language specific storyboards. Over time they also became inconsistent. The english board has all the current changes and the dutch one does not.
My question is:
How can i safely remove these language specific storyboards and just keep using the localizable.strings. I want to end up with only 1 main storyboard (the top level one in the image above). I do not want to ruin my project and i want to be sure that the solution i use is correct.
Thank you!
I had the same issue.
I solved it by selecting "Base internationalization" in the project settings. Next, click the file inspector icon (right pane) for your storyboard file and make sure only Base is checked. Do not check the other languages.
This will fix the issue.
Don't bother with Base internationalization for your localizable.strings file, you can still use your regular translation setup there (ie, English and Dutch).
To "roll back" a localized File. you have to navigate to the folder where your class should be. You see the folder "en.lporj" (and the other languages) and there is the file you need.
-
Now copy to a save place, remove the multi-language file and in xcode and tell to remove from disk. Copy it again into your folder where you need it and import it in xcode.
Now the settings for the translation are resettet. you should recheck if no links went lost (simple clean build should be enought for this).
I handle only .xib file at the moment, but the procedure should be the same for all files :)
(if not, please let me know :D)
Greets,
geo

My app crashes in other languages. Xibs seem to not be loaded. Why?

I have an app that is localized for two languages: English and Danish. If I set the device to any other language (say, French) the app crashes. It seems as if it's not really loading the XIB files, or getting a generic version of them that is not properly initialized.
I guess that I naively assumed that the app would load the English version if it was set for a language other than English or Danish.
What do I do? Is there a way to ensure that behavior?
Cause:
Somehow XCode had created two sets of en.lproj and da.lproj directories. One set was in the project root (oh, an en.lproj was here called English.lproj) and the other was in Classes. The "missing" XIB files were in the directory in Classes.
Solution:
Copy XIB files to the proper folders in the root. Remove original ones from project (go ahead and say move to thrash, you just copied them...). Add copies in proper location to project - all in one drag operation - and do not copy to project (they are already in the proper location).
The app should load the english version if you set the device language to, for example, french.
You should give some details how you are loading the XIB.
It's rather impossible to give an answer to this question without knowledge about your specific implementation.

Resources