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!
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.
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.
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) ...
Based on your responses, my own answer in the comments seems to work. So here it is as an official answer:
Choose one of the localized files in the group (e.g. infoPlist.strings, CustomLocalizable.strings): Click on the file in the project tree
In the File Inspector, in the localization pane, remove all languages for which the files have an absolute path, using the '-' button.
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'
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With