Introduction

The IB file format is an instance of XML, but neither a DTD nor a schema is available. The file content is based on the XML serialization available in Cocoa, which means that some objects are builds in a non-hierarchical manner. It is used for the *.xib files and for designable.nib files found in NIB bundles.

Note

The following document is based on observations of various *.xib files and element properties have been inferred. There was not code reverse engineering involved what so ever.

Base64 values

Base64 encoded values are alpha-numeric strings with a lengh that is a multiple of 4. A padding character '=' is used to have the required length if the encoding result length in a not a multiple of 4. But Apple has (deliberatly ???) choose not to follow the classic encoding: the padding characters are either stripped, or sometimes the base64 encoded strings have useless additional characters.

Elements

Here is the list of elements contained in the file format:

  • IB Archive <archive/>
  • IB Data <data/>
  • IB Boolean <bool> or <boolean/>
  • IB Integer <int/> or <integer/>
  • IB Float <float/> or <real/>
  • IB Double <double/>
  • IB String <string/>
  • IB Bytes <bytes/>
  • IB Nil <nil/>
  • IB Reference reference/>
  • IB Object <object/>

IB Archive <archive/>

This is the root element of the file. It contains information of the format of the archive. It has the following attributes:

Attribute Description
type Indicates the type of the file (either for Cocoa or for CocoaTouch)
version Indicates the version of the file.

Examples for Interface Builder 3.0:

<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
...
</archive>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.02">
...
</archive>

Example for Interface Builder 3.2:

<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
...
</archive>

Example for XCode 4.0:

<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
...
</archive>

IB Data <data/>

This is a structural tag to delimit the content of the archive. Example:

<data>
...
</data>

IB Boolean <bool> or <boolean/>

This tag holds a boolean value, either as its content or as an attribute. If the "value" attribute is not specified, then the textual content of the tag is used as a value.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.
value Attribute that hold the value. If it is "YES", then the boolean has the value true, otherwise false.

Examples:

<bool key="NSIsDisabled">YES</bool>
<boolean value="YES"/>

IB Integer <int/> or <integer/>

This tag holds an integer value, either as its content or as an attribute. If the "value" attribute is not specified, then the textual content of the tag is used as a value.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.
value Attribute that hold the value.

Examples:

<int key="IBDocument.SystemTarget">1050</int>
<integer value="1" id="9"/>

IB Float <float/> or <real/>

This tag holds a single precision floating value as its content. The content uses scientific notation.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.

Example:

<float key="IBUIValue">5.000000e+01</float>

IB Double <double/>

This tag holds a double precision floating value as its content. The content uses scientific notation.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.

Example:

<double key="NSSize">1.300000e+01</double>

IB String <string/>

This tag holds an string value as its content. The default encoding is UTF-8.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.
type If specified, contains the encoding type of the string. Values can be either UTF8 or base64-UTF8.

Examples:

<string key="IBDocument.SystemVersion">9J61</string>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>

IB Bytes <bytes/>

This tag holds a binary value as its content. The content is base 64 encoded.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.

Example:

<bytes key="NSWhite">MCAwLjI4OTk5OTk5AA</bytes>

IB Nil <nil/>

This tag holds a null reference as its content.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.

Example:

<nil key="NSNextResponder"/>

IB Reference <reference/>

This tag holds a reference to another tag, in order to avoid duplication of content. This is especially useful when the referenced tag is big. The main drawback is that a reference resolver is needed to find the referenced tag.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.

Example:

<reference key="NSMenu" ref="649796088"/>

IB Object <object/>

This tag holds the description of an object. Depending on the class of the object, the inner tags may contains further informations or value.

It has the following attributes:

Attribute Description
id A unique identifier to allow references.
key An application-specific key.
class The class of the object.

IB Object - NSArray and NSMutableArray

When the class attribute of the object tag contains NSArray or NSMutableArray, the inner tags contains an element to indicate the XML serialization and the elements of the array.

Example:

<object class="NSMutableArray" key="children">
    <bool key="EncodedWithXMLCoder">YES
    <reference ref="601701719"/>
    <reference ref="334170355"/>
    <reference ref="1001122846"/>
    <reference ref="431464563"/>
    <reference ref="692045935"/>
    <reference ref="383511723"/>
</object>

IB Object - NSDictionary and NSMutableDictionary

When the class attribute of the object tag contains NSDictionary or NSMutableDictionary, the inner elements may contains: a <boolean/> element to indicate the XML serialization and two serialized array of elements: either one for the keys and one for the values or a series of pair elements with a key element, followed by a value element.

Examples:

<object class="NSMutableDictionary" key="flattenedProperties">
    <bool key="EncodedWithXMLCoder">YES</bool>
    <object class="NSMutableArray" key="dict.sortedKeys">
        <bool key="EncodedWithXMLCoder">YES</bool>
        <string>-1.CustomClassName</string>
        <string>-2.CustomClassName</string>
        <string>1.IBEditorWindowLastContentRect</string>
        <string>1.IBPluginDependency</string>
    </object>
    <object class="NSMutableArray" key="dict.values">
        <bool key="EncodedWithXMLCoder">YES</bool>
        <string>viewController</string>
        <string>UIResponder</string>
        <string>{{156, 392}, {320, 460}}</string>
        <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
    </object>
</object>
<object class="NSMutableDictionary" key="actions">
    <string key="NS.key.0">updateNow:</string>
    <string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary">
    <string key="NS.key.0">InitialTabViewItem</string>
    <object class="IBInitialTabViewItemAttribute" key="NS.object.0">
        <string key="name">InitialTabViewItem</string>
        <reference key="object" ref="712502892"/>
        <reference key="initialTabViewItem" ref="107038816"/>
    </object>
</object>

IB Object - IBPartialClassDescription

When the class attribute of the object tag contains "IBPartialClassDescription" the inner elements describes the class information, its actions and outlets, along with the header source file. Note that a class can have multiple IBPartialClassDescription objects because several sources can collaborate to the class definition (IB, Header File, etc).

Example:

<object class="IBPartialClassDescription">
    <string key="className">MyController</string>
    <string key="superclassName">NSWindowController</string>
    <object class="NSMutableDictionary" key="actions">
        <bool key="EncodedWithXMLCoder">YES</bool>
        <object class="NSMutableArray" key="dict.sortedKeys">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <string>imageSpacingChanged:</string>
            <string>indentChanged:</string>
            <string>removeSelectedQueueItem:</string>
            <string>revealSelectedQueueItem:</string>
            <string>showQueueWindow:</string>
        </object>
        <object class="NSMutableArray" key="dict.values">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <string>id</string>
            <string>id</string>
            <string>id</string>
            <string>id</string>
            <string>id</string>
        </object>
    </object>
    <object class="NSMutableDictionary" key="outlets">
        <bool key="EncodedWithXMLCoder">YES</bool>
        <object class="NSMutableArray" key="dict.sortedKeys">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <string>fCurrentJobPane</string>
            <string>fIndentation</string>
            <string>fJobDescTextField</string>
            <string>fJobIconView</string>
            <string>fOutlineView</string>
            <string>fProgressBar</string>
            <string>fProgressTextField</string>
            <string>fQueueCountField</string>
            <string>fQueuePane</string>
            <string>fSpacing</string>
        </object>
        <object class="NSMutableArray" key="dict.values">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <string>NSView</string>
            <string>NSSlider</string>
            <string>NSTextField</string>
            <string>NSImageView</string>
            <string>HBQueueOutlineView</string>
            <string>NSProgressIndicator</string>
            <string>NSTextField</string>
            <string>NSTextField</string>
            <string>NSView</string>
            <string>NSSlider</string>
        </object>
    </object>
    <object class="IBClassDescriptionSource" key="sourceIdentifier" id="333889241">
        <string key="majorKey">IBProjectSource</string>
        <string key="minorKey">HBQueueController.h</string>
    </object>
</object>