10

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!

THelper
  • 15,333
  • 6
  • 64
  • 104
Visionscaper
  • 3,979
  • 1
  • 23
  • 26
  • 7
    I found the answer to my own question: 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' I hope this helps you as well. Cheers, Freddy – Visionscaper Aug 11 '11 at 14:03
  • Thank you man, it works! You should add this as your own answer for other people to see this is solved! Cheers – Omer Oct 13 '11 at 18:12
  • 1
    @FreddySnijder you're my hero dude, so thanks :) – relower Nov 30 '11 at 17:49
  • Thanks, this worked for me using Xcode 4.2. This is definitely a bug on Apple's part, to set all localizations as absolute paths. – jd. Dec 01 '11 at 03:17
  • @Omer Relower and jd, a bit late, but I'm happy this worked out for you; I just added my answer as an official one. – Visionscaper Feb 13 '12 at 10:08

3 Answers3

8

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'

Visionscaper
  • 3,979
  • 1
  • 23
  • 26
  • @ShivanRaptor, I have tested this, and these actions do not replace my existing localized files. BTW as an alternative, i actually solved this problem by simply editing my project file and grepping absolute paths into relatives. Still unfortunate that Apple's default is (incorrect) absolute paths. – jd. Jul 06 '12 at 02:27
2

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!

jd.
  • 1,142
  • 8
  • 14
0

You can change a file's path without removing it and re-adding it:

  1. In the Project Navigator, locate the missing files (colored red for not being found) and highlight one of them.
  2. Show the File Inspector
  3. Under Location change Absolute Path to Relative to group or Relative to project,
  4. Then next to the path, there's a little white icon, click it and choose the file's location.
marmor
  • 27,641
  • 11
  • 107
  • 150