Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the location of a grouped (localization) file from an absolute to a relative path in XCode 4?

I'm having problems with making all file location paths relative in XCode 4.

I have multiple infoPlist.strings and CustomLocalizable.strings (for different languages) grouped together (XCode does this automatically). When looking at the File Inspector (View >> Utilities >> Show File Inspector) for these files (except for the English which is the default language) the Location is 'Absolute Path'.

The problem is that the Location dropdown menu for these files in the File Inspector is grayed out, it's disabled. This keeps me from changing the file location from an absolute path to a relative path description.

What do I need to do to make all path locations of the files in the group relative?

I have already tried to change the path location of the file group to, for instance, 'relative to group' or 'relative to project'. For the group I also set the relative path clicking the small icon blow the location dropdown in the file inspector.

I've been searching to find a solution for a while now and appreciate if anyone could help me answer the above question.

Thank you!

like image 655
Visionscaper Avatar asked Aug 11 '11 09:08

Visionscaper


People also ask

How do you convert an absolute path to a relative path?

The absolutePath function works by beginning at the starting folder and moving up one level for each "../" in the relative path. Then it concatenates the changed starting folder with the relative path to produce the equivalent absolute path.

How do you specify a relative path?

Relative path Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy. A single dot represents the current directory itself.

What is relative and absolute file path?

An absolute path is defined as specifying the location of a file or directory from the root directory(/). In other words,we can say that an absolute path is a complete path from start of actual file system from / directory. Relative path. Relative path is defined as the path related to the present working directly(pwd) ...


2 Answers

Based on your responses, my own answer in the comments seems to work. So here it is as an official answer:

  1. Choose one of the localized files in the group (e.g. infoPlist.strings, CustomLocalizable.strings): Click on the file in the project tree

  2. In the File Inspector, in the localization pane, remove all languages for which the files have an absolute path, using the '-' button.

  3. Add the languages again, using '+' >> 'Add all' or the specific language. The grouped and localized files will show up again in the tree. In the file inspector you will see that the location changed to 'Relative to group'

like image 90
Visionscaper Avatar answered Oct 27 '22 10:10

Visionscaper


Thanks, the answer provided as a comment in the question worked for me in Xcode 4.2. This is definitely a bug on Apple's part, to set all localization file entries as absolute paths.

Another option... search your project.pbxproj for your strings file and look out for absolute paths. You might be able to just edit the entries in a text editor to look like this:

9E0D4EC0148727D300456F82 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };

If someone has tons of files and the UI method of doing this would be too slow, try it!

like image 39
jd. Avatar answered Oct 27 '22 09:10

jd.