Subversion and Interface Builder
01 January 2000
in code
tagged with
[development]
[macos]
[subversion]
Panther-specific notes about my problems with Interface Builder and storing .nibs in subversion.
The Problem
When writing apps with XCode, the files that Interface Builder deals with are NIB(Next Interface Bundle)s. These are package files, ie they’re actually directories that the finder considers ‘special’, and which can hide a lot of other files that the user can’t see. Quite a lot of stuff on Mac OS X is a package file, and I think it’s a really lovely way of distributing applications. It’s great for everything, in fact, until you hit something that doesn’t manipulate the file through the Finder, but uses the UNIX layer or something instead. For instance, you can’t email a .app to someone. Enter Subversion. I’d like to use it to manage my XCode projects. This involves managing quite a lot of packages, including .nibs. This means that there will be a .svn folder inside the .nib bundle, containing the subversion metadata. There are 2 problems that I have experienced thanks to this:
The Document “MainMenu.nib” is read-only
Because some of the files in a .svn folder are read-only (I don’t know why, and I don’t care), IB(Interface Builder) thinks that the whole package is read-only. The fix? Make all the files in the .nib file writable by the user.
$ cd MainMenu.nib
$ chmod -Rv u+w .svn
Now IB will be able to open the nib and change things. Annoyingly, you have to do this after ”every commit”. Gah, annoying. And then we hit the other issue.
The .svn folder vanishes (Working copy ‘MainMenu.nib’ not locked)
It turns out that whenever you save a folder, IB will move the existing .nib file out the way, and create a new one, instead of changing the files in the folder. It’ll keep the old version as a backup, if you have ‘create backup files’ turned on, or throw it away if not, but the crucial problem is that the newly-created folder doesn’t have a .svn folder in it, and so subversion will get confused.
Fortunately, there was this same problem with CVS, and so there’s a (panther-only, apparently) fix for it - we tell XCode/IB that .svn files are also version control files, and should be special.
$ defaults write com.apple.InterfaceBuilder \
VersionControlDirectory "(CVS, .svn)"
Now IB knows that it must keep the .svn folder from the old copy of the nib, and put it in the new copy as well.
I hate computers. But these two fixes have solved my immediate problem.