I'm trying to follow the tips in Apple's I18N and L10N Guide. I have a pre-existing project from which I have (long ago) deleted the Base.lproj folder. Why? Because I have no Main.storyboard or LaunchScreen.xib. Both of those things are handled programmatically.
However I do have a large number of subsidiary storyboards, including a WatchKit Interface.storyboard. When I click the + in the Project (not target) Localizations section, Xcode presents a dialog that lists only the Interface.storyboard file. Not any of the many others.
How can I persuade Xcode to help me localize the other storyboards? Can I do this all manually? As usual, I am sure it is my mental model that needs refinement.
This is an example where configuration yields convention. That is, if you customize your folder hierarchy, Xcode can adapt and implement its naming conventions.
Select storyboard file in left pane (Project navigator)
Click Doc icon (File inspector) in right pane
Click Localize...
This will create a new Base.proj folder inside whatever folder holds the storyboard. If you are like me, you have done lots of folder-factoring. Xcode goes along with this.
Then you go back to the Project Localizations section and click + to add locales. Xcode creates extracts the strings from your storyboard and creates new folders for the corresponding .strings files.
In Xcode have added two localizations, German and English. I am following documentation on Apple regarding "Use Base Internationalization" which is obtained by going to the project, clicking Info and pressing on the checkbox.
If I do this, it launches a pane or page which is empty.
IE:
How do I get it to be populated, or otherwise be in a situation to select the relevant resource file?
The answer is to localize your storyboards. Go to storyboard, there is a button called localize. If you do this, the pane is no longer empty.
Check the answer from hassan83 (https://stackoverflow.com/users/1586924/hasan83) in another question. It solved my problems.
https://stackoverflow.com/a/27720065/7017099
"This could happen if Base Internationalization was active before then disabled and files deleted manually.
Create Base.lproj folder in your project folder using the finder.
Move your main story board to it also using the finder.
Fix the reference to it from Xcode.
Remove app from device, clean & build
your project.
All will be back to normal."
I'm trying to localize an existing application. Here is a simple thing that I can't make work:
I have added the needed languages into localizations from the project info tab
Activated the l10n for one of my storyboards
Adapted the strings into the newly created .strings files
Cleaned the app
Removed the app from the simulator
Relaunched the app in the simulator
Changed the language in the simulator
No effect...
I am used to i18n in other languages & frameworks and I have to say I never saw it as complicated & unintuitive as in Xcode.
Could someone help me with that ? Am I forgetting something here ?
Here is how I fixed it:
Disable localizations for each resource
Make sure to have Use Base internationalization checked from the project's Info tab
Move all resources that needed localizations somewhere specific (From Finder)
Reattach the references from Xcode (with the right Utilities panel location folder button)
Activate localizations for each resource selecting Base as base
The last step moves each file into Base.lproj and creates a strings files into each selected {lang}.lproj.
For future files to localize, don't put them into Base.lproj yourself, otherwise Xcode will create another Base.lproj subfolder to move the file into.
I think that Xcode organizing files into his own "groups" (almost) totally disconnected from the real folder hierarchy is the thing that constantly confuses me (not even talking about git). I don't really understand the advantage of having this detached hierarchy.
I think I'm literally on the last step before submitting a new Mac app, and I've been banging my head against a wall for the past few hours on what I think should be really, really easy.
I've designed document icons for the two different types of icons my app creates and works with. I created a new "Icon" in Images.xcassets, and dropped the appropriate files into the drop zones.
In the product editor -> Info, I go to where the document type information is, but when I try to enter in the icon name in the "icon" field of either the Document Types or Exported UTI section, the icon image just turns into a question mark—no options show up in the drop down menus for icons.
How do I get the images/icons in the asset catalog to show up in the editor? Alternatively, if I was going to enter that manually into the plist, what sort of format would I use to reference an Icon file from the asset catalog?
I know I'm probably missing an easy step here, but I can't see it!
To my knowledge, Xcode doesn't currently support using .xcassets for document icons. This is a little strange—the .xcassets editor clearly allows you to create new icons, but it doesn't generate .icns files, it just puts all the files in the same folder and uses a plist to manage them.
To create an icon for your document types, upload the 1024x1024 version of the icon to http://iconverticons.com/online/ to convert it to a .icns file. Alternatively, you could use a third-party tool to generate an .icns file with different images for different resolutions. There used to be a great tool included in the Developer Tools for doing this, but I can't seem to find it anymore.
Once you've got an icns file, add it to your project and you should be able to select it as the "Icon" for your Document Type or External/Internal UTI. Enjoy!
To be honest, it might be worth filing a bug about this. Xcode's development seems so strongly driven by iOS these days, they may not have noticed this yet!
I did it in the most easy way:
Add "New OS X Icon" to images.xcassets and name it "DocIcon", for instance.
Drag and drop images of your document icon
Just type "DocIcon" to icon name of your document
You will see question mark as document icon thumbnail. Don't care about. All will work fine after build and launch of application.
This is what worked for me, using Xcode 10 in 2019 (none of the other answers worked in my case):
Select asset catalog in Project Navigator
Right click on the left pane (list of assets) and choose App Icons & Launch Images ▶︎ New macOS Generic Icon (second option from bottom). Name it "Document". This will create a folder named "Document.iconset" in the asset catalog directory.
Populate all entries with your custom images. They must all be of the appropriate size (e.g., "16 x 16 #2x" must be 32 x 32 pixels, otherwise you will get yellow a warning icon over the image slot).
Navigate to the asset catalog folder, and use the command: iconutil -c icns Document.iconset (must match the name of the icon created in step #2). I took this command from Apple's documentation here (which by the way, also says some BS about Xcode "automatically creating an .icns file from your .iconset folder on build". Sure...).
Copy the newly created Document.icns file as a resource to your project.
Select the target, open the Info pane, and in both Document Types and Exported UTIs set your .icns file as the icon for the file type.
Hej, allesamme,
I had the same problem and have been researching it for days. I found a family of four solutions, the first three of which did not work for me: 1. using a .png file as the document type icon file; 2. using a manually created .icns file as the document type icon file; 3. the above solution, and 4. what I will describe here. Only the last one worked for me.
I tried following the spirit of the above advice and found that it didn't work, at least for my MacOS app. I'm on OS X 10.9.2 (13C64) running Xcode Version 5.1 (5B130a).
The current wisdom seems to be to create a directory in your workspace with a lower-case name and .iconset extension, in which one puts files with an icon_ prefix and the usual suffixes (16x16.png, 16x16#2x.png, 32x32.png, etc.)
In Product Editor's Info pane you can go into Document Types and associate the .iconset file with the Icon field. The icon image happily displays something reasonable. The build process builds a .icns file from that spec and copies it into your app.
I had an intermittent problem that the .icns file wouldn't build, which I traced to mistakenly haven included a 64x64 icon in the list. That's a no-no.
The current Apple dogma on this issue can be found in the official documentation, which covers some details I glossed over here. I didn't need to edit the Info.plist file directly: everything seemed to work from the interfaces provided in Xcode.
I have no idea which solutions work in which contexts, but thought I'd add throw more alternative on the fire for people to try out. — Jim Coplien
We localized a project recently into to 15 languages using Xcode but I noticed when I took the project home the paths to some of the localized files were all hardcoded to the full path of my work mac.
We only localized two files:
InfoPlist.strings
Localizable.strings
We used Xcode to do the localisation as follows.
We added the 15 languages to the whole project.
Then clicked on Localizable.string and in
File Inspector > Localisation > +
clicking + we added it to the 15 languages we set up for the whole project.
Localizable.strings then moved into
en.lproj/Localizable.strings
fr.lproj/Localizable.strings
etc.
We sent
en.lproj/Localizable.strings
to the translators and as each returned we replaced the file in each translation folder.
This was done through Finder not dragging files into XCode (I think, it was a while ago)
To meet deadline I took the project home but when I opened it all the localized files except English were showing red in XCode as if the file was missing.
In finder they were there but I checked File Inspector/Full Path and it was hardcoded to the path of my work mac.
Also the LOCATION drop down was set to ABSOLUTE PATH for the missing files
but is DISABLED so cant change it to RELATIVE TO GROUP.
I noticed the path included a folder with a space so thought maybe this might be the problem though then EVERY file in the project should have problems.
Only way to fix it was tob back up using Finder/Duplicate on each .strings file using Finder.
Then click on Localizable.strings in Xcode (top level/ not individual localization)
Then in File Inspector delete the missing Localizations and re-add it.
This will ask you to replace the existing file (it copies the en.lproj version over it, thats why you need to back up with Duplicate)
so after you need to go back into Finder and put the Duplicate back.
any idea why it happens?
or how to change it easily (Location drop down is disabled).
Any idea why the drop down to set a file RELATIVE TO THE GROUP is disabled.(I presume its because XCode manages the Localisation)
cheers