Steve H.
Steve H.

Reputation: 253

Decompiling or interpreting XIB/NIB files on iOS

I've investigated understanding the NIB/XIB format quite a bit, and I cannot seem to find much information on the subject. I'm interested in understanding how iOS encodes events to button presses and the like. For instance, I know that buttons and the handlers they call can be dynamically allocated, but I'm specifically interested in knowing how to decode the NIB/XIB so that I can know which click event is called for a given button. I'd be interesting in knowing how the IBOutlets connect and how I might know what function is reachable from a certain event.

I've developing an automatic testing framework and this feature would greatly help the usability of my tool. Thanks a lot for any insight you might provide.

Upvotes: 2

Views: 2246

Answers (2)

Thomas Tempelmann
Thomas Tempelmann

Reputation: 12095

I've found a format description here:

https://github.com/matsmattsson/nibsqueeze/blob/master/NibArchive.md

Also, to clarify: These nib files in question, both in XML (bplist) and "NIBArchive" format, are compiled nibs that can't be viewed with Xcode nor processed by ibtool.

See also my related question: Extract translatable strings from "NIBArchive" .nib files

Upvotes: 1

Patrick Goley
Patrick Goley

Reputation: 5417

If you open the .xib file in a text editor, you will see that it is encoded in XML. The arrangement XML nodes describes the structure of the view hierarchy, as well as values to be assigned to given key paths or control states of those views. You can see IBAction connections described like so:

<connections>
    <action selector="buttonPressed:" destination="-1" eventType="touchUpInside" id="290"/>
</connections>

The selector of any action connection should be implemented by the File's Owner, which you can find as the first element under the <objects> section. It will look like this:

<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SomeViewController">

It is also important to note the <resources> section, that describes any resources (usually images) that are used by the xib.

Upvotes: 0

Related Questions