When one takes a non-localized XIB file in Xcode, and makes it localizable, it automatically adds the default region/localization to the XIB file, e.g. "en" or "English." This actually moves the XIB file into the en.lproj or English.lproj directories. If the XIB file is in a version control system such as SVN, SVN starts to freak out because the file was not moved within the version control system, and it thinks that it is missing. What to do? Is there a way to have Xcode move the XIB files in a version control-friendly way, or do I need to move the files with the SVN command-prompt in Terminal?
2 Answers
I figured I'd post my own solution to this problem. It's not the most "elegant" solution, but it works for me. Essentially, I don't "localize" the XIB files directly, but I hook up every UI object that has text in it to an IBOutlet, and set the text programmatically in my UIView class. That way, all of my strings end up in the regular strings files rather than having a separate set of strings files for the XIB files. So far, it's working pretty well.
When I originally attempted to localize an .xib file that was checked in to SVN, I initially got the "svn: Can't move '{path}/.svn/tmp/entries' to '{path}/.svn/entries': Operation not permitted." error.
Based on this blog post (http://www.devcha.com/2008/03/mac-os-cant-move-svntmpentries-to.html), I successfully fixed the error by performing the following in the directory containing the .xib file in question from the terminal:
- cd {folder that holds the .xib file you want to localize}
- chflags -R nouchg .
- svn up
- svn cleanup
I was then able to localize the .xib file from within Xcode. Afterwards, SVN correctly tracked the deletion of the .xib file from the folder in question as well as the addition of the new localized folder (en.lproj in my case) and the moved .xib file to this new folder.
Based on the man entry for chflags, -R stands for "Change the file flags for the file hierarchies rooted in the files instead of just the files themselves.", "nouchg" stands for "clear the user immutable flag (owner or super-user only)" and using the "." character afterwards applies the change to to the current folder.