Editing xib files for rapid UI building

I just decided to look at what a .xib file contained. The “x” should have been the clue that it just might be an XML form of a .nib file. If you’re lost, I’m talking about the files that the Apple Interface Builder tool uses to store interface definitions.

I needed to copy an existing interface, then make minor tweaks. Starting from scratch in Interface Builder isn’t so bad, but I’m really a Vim guy of old and being able to fly through a text file and make edits is 2nd nature to me. If you’ve ever edited XML manually, this won’t seem like a silly notion. For that matter, you could use any of the XML editors out there as well.

To start with, I copied the existing .xib to a new name. In Vim, I changed the references to the old name to the new one. So, now my new interface also references a new controller class, which I’ll probably copy/paste also. It’s pretty trival to change the button text and IBActions and IBOutlets the .xib points to. There are a lot of reference numbers within the XML, so I wouldn’t do too many changes for fear of messing up some relationships that Interface Builder requires. Also, don’t forget to add (existing file) to your project, so that you build with the new interface def.

Happy .xib editing!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s