问题
I've recently upgraded from Xcode 3 to Xcode 4.2, and migrated an existing iOS apps to use this new version. This app is localized, and I now want to add another language.
Under Xcode 4, when I add the new localization, it creates the country specific folder in the project root. For example:
/fr.lproj
All of my prior language folders are in a Resources sub-folder, however. Such as:
/Resources/de.lproj
/Resources/en.lproj
For the life of me I cannot figure out how to get Xcode 4 to move the new language folder to Resources. There is no GUI option I can find. If I move the physical folder using Finder, Xcode just changes the reference to red, but gives me no option to fix it.
Can anyone help?
UPDATE:
Here are a few screenshots demonstrating the problem (using Chinese this time):
The file listing:
The identity section for that file. Note that I can't change it:
回答1:
Found the solution. It's not pretty, but it works.
Here's what I did:
- View the contents of the
.xcodeprojfolder in Finder - Edit the
project.pbxprojfile - Search for
.lprojwithin the file - Change the
path =section to include theResourcespart of the path. - Save, then restart Xcode
This smoothed everything over, and allowed the Localization to reside in the Resources subdirectory.
回答2:
Here's a way how to solve it w/o editing .pbxproj file (Xcode 4.6.3):
- select localization parent file (Localizable.strings)
- Utility pane > Identity and Type > under Location (Relative to Group) choose path icon and set required new location for localization files
- Finder > move all your en.lproj, fr.lproj, etc subfolders to that chosen folder
UPD: doesn't work in Xcode 8 :(
回答3:
This way works on Xcode 5.1 also (Greek example):
- Create
Resources/el.lprojfolder withinLocalizable.stringsfile in Finder - Open your project file in Xcode and right-click on
Resourcefolder - Click on "Add File to..." context menu item
- Select Localizable.strings file from
Resources/el.lprojfolder -> OK. GreekLocalizable.stringsautomatically will be added toLocalizable.stringsfiles.
You can use the same way to add localization for xib files.
回答4:
The file structure on disk is mostly irrelevant in Xcode. Just move the directory in Finder, then in Xcode you can either: (a) remove the fr.lproj directory and re-add it, or (b) select the red entry, open the right-hand (properties) panel, and near the top you should see the path. Change the path to the new location and it'll go back to black.
来源:https://stackoverflow.com/questions/10237285/moving-localization-folders-in-xcode-4