Xcode 5 was released today along with iOS 7. If you are an iOS or MacOS X developer who
uses XIBs and Storyboards in their projects, one of the most significant features to be
added to Xcode 5 is the new file format for these files.
If you are a Cocoa developer who has sworn off using XIBs and Storyboards because of
the old file format and the trouble that it brings with merging and understanding, it is
time to reconsider your position.
You may be asking, why is this such a huge event? Well, in the past this is what XIBs
The files were huge, nasty messes of XML that Xcode would change and re-order on a whim.
While it might have been possible to build a mental model of what user interface the XIB
represented it was very hard so no one bothered.
With Xcode 5 XIBs are still XML but they are now XML that a human might write by hand.
The benefits of this new XIB XML format are many fold:
XIBs are much smaller (fewer lines of code).
A developer can easily read the XML and understand what it specifies in the user interface.
Merging XIBs is now much less likely to lead to broken XIBs. Before we would rarely even bother to try and merge a XIB or Storyboard.
It might be possible for 3rd party tools to be built around the new XIB format. We’ll probably need an actual DTD to be published by Apple for this to be truly reliable though.
The new (much better) Auto Layout workflows in Xcode 5 are enabled by the new XIB format.
So if you’ve not done so already I highly recommend updating your project’s XIBs to the
new Xcode 5 format. Xcode 5 should prompt you to do so the next time you open a XIB but if
it does not you can just change the Interface Builder Document properties in the Xcode
inspector for a XIB file and then save the XIB file again (as shown to the right).
Bear in mind that once you upgrade you wont want to go back to Xcode 4 style XIBs (even
though it is technically possible). So before you do so ensure that this isn’t going to
be a problem for your team or build servers.
Go forth and convert!
Oliver Jones is the Technical Director at Itty Bitty Apps.
He spends his days building the iOS Introspection tool Reveal
and playing Pinball. You can follow him on twitter @orj.