1.nib vs .storyboardc
| Compiled form | Source | Contents |
| Foo.nib (file) | Foo.xib | One archive with every object of the xib. |
| Foo.nib (folder) | Foo.xib | When the xib needs different objects per OS version or device, a folder with runtime.nib and variants such as objects-13.0+.nib; UIKit picks one at load. |
| Main.storyboardc (folder) | Main.storyboard | An Info.plist naming the entry point (UIStoryboardDesignatedEntryPointIdentifier) and mapping view-controller identifiers to nib names (UIViewControllerIdentifiersToNibNames), and one nib per scene: the view controller (UIViewController-BYZ-38-t0r.nib) and, separately, its view (BYZ-38-t0r-view-8bC-Xf-vdC.nib), loaded when the view is first needed. |
The odd identifiers (BYZ-38-t0r) are Interface Builder's object IDs from the source document. Segues are compiled into objects inside the view controller's nib. Open each nib of a storyboard separately; the scene's interesting content is usually in the …-view-….nib.
Inside the file, iOS (and current macOS) uses the NIBArchive encoding; older macOS nibs use an NSKeyedArchiver binary plist. The tool recognises both by their first bytes (NIBArchive or bplist). An XML file (<?xml, <document) is an uncompiled xib or storyboard.
2The NIBArchive format
A 50-byte header, then four tables. All fixed-size integers are little-endian u32.
"NIBArchive"+0 · 10 bytes
format+10 · u32
coder+14 · u32
objects+18 · count, offset
keys+26 · count, offset
values+34 · count, offset
class names+42 · count, offset
| Offset | Size | Field | Meaning |
| 0 | 10 | magic | The ASCII bytes NIBArchive, no terminator. |
| 10 | 4 | format version | Archive format version (1 in current files). |
| 14 | 4 | coder version | Version of the UINibEncoder that wrote it (e.g. 9, 10). |
| 18 · 22 | 4 · 4 | object count · offset | Object table. |
| 26 · 30 | 4 · 4 | key count · offset | Key-name table. |
| 34 · 38 | 4 · 4 | value count · offset | Value table. |
| 42 · 46 | 4 · 4 | class count · offset | Class-name table. |
Offsets are from the start of the file. The tables are packed one after another, usually in the order objects, keys, values, classes, but a reader should use the offsets.
3Varints
Counts and indices inside the tables are variable-length integers: 7 bits per byte, least significant group first. Unlike LEB128, the high bit is set on the last byte, not on the continuation bytes.
5 = 0b101 → 85
300 = 0b10_0101100 → 2c 82
2c = 44 (continuation: high bit clear)
82 & 0x7f = 2 × 128 (last byte: high bit set)
44 + 256 = 300
70000 = 0x11170 → 70 22 84 (0x70 + 0x22 × 128 + 0x04 × 16384)
4Objects, keys, values, classes
Every object is an instance of a class and owns a contiguous run of values; every value is a key and a typed payload. Archiving an object writes the values its encodeWithCoder: produces: [coder encodeObject:self.subviews forKey:@"UISubviews"] becomes one value with key UISubviews and an object reference.
| Table | Record | Fields |
| Objects | varint × 3 | class index (into the class-name table) · values start (index of its first value) · value count. Object 0 is the root. |
| Keys | varint + bytes | length, then the key name in UTF-8 (no terminator): UISubviews, UIFrame… |
| Values | varint + byte + payload | key index · type (one byte, below) · payload, whose size depends on the type. |
| Class names | varint × 2 + u32 × n + bytes | length · extra count n · n fallback class indices (u32 each) · the name in UTF-8, NUL-terminated (the length includes the NUL). |
Fallback classes name other entries of the class table that can stand in when a class is not available at run time. Key and class names are shared: UIView appears once in the class table however many views there are.
Collections and strings
- An
NSArray, NSSet or NSDictionary object stores its elements as values with the key UINibEncoderEmptyKey (dictionaries alternate keys and values), typically after an NSInlinedValue marker.
- An
NSString object stores its text as a data value with the key NS.bytes (UTF-8). There is no string value type: every string, even a one-letter title, is a separate object.
NSNumber, UIColor, UIFont, NSValue and the like are objects with their own keys (NS.intval, UIRed, UIFontName…).
5Value types
| Type | Meaning | Payload |
| 0 | int8 | 1 byte, signed |
| 1 | int16 | 2 bytes, signed LE |
| 2 | int32 | 4 bytes, signed LE |
| 3 | int64 | 8 bytes, signed LE |
| 4 | true | none |
| 5 | false | none |
| 6 | float | 4 bytes, IEEE 754 |
| 7 | double | 8 bytes, IEEE 754 |
| 8 | data | varint length, then that many bytes (strings' NS.bytes, encoded structs such as rects and points, images) |
| 9 | nil | none |
| 10 | object reference | u32: index into the object table |
Integers are written in the smallest type that holds them, so a reader must accept all four widths for the same key. Geometry (UIBounds, UICenter, UIFrame) is usually a data value holding packed numbers, not separate keys.
6A worked example
A label with the text "Welcome", decoded from the tables:
classes #3 len 8, extra 0, "UILabel\0"
#7 len 9, extra 0, "NSString\0"
keys #12 "UIText" #20 "NS.bytes" #31 "UIHidden"
objects #42 class 3 (UILabel), values 310 … 318
#43 class 7 (NSString), values 319 … 319
values #314 key 12 (UIText), type 10, u32 43 → object #43
#316 key 31 (UIHidden), type 4 → true
#319 key 20 (NS.bytes), type 8, len 7, "Welcome"
bytes of value #314: 8c 0a 2b 00 00 00
│ │ └ object 43
│ └ type 10 (object reference)
└ key 12 (varint, last byte: high bit set)
So object 42 is a UILabel showing "Welcome" — and it is hidden.
7NSKeyedArchiver binary plists
Older macOS nibs (and many other Apple archives: preferences, NSUserDefaults blobs, state restoration data) are an NSKeyedArchiver archive stored as a binary property list.
Binary plist layout
The file starts with bplist00, then the objects, then an offset table, then a 32-byte trailer: 6 unused bytes, the size of an offset-table entry (u8), the size of an object reference (u8), the object count, the index of the top object and the offset of the offset table (u64 each, big-endian). Each object starts with a marker byte: high nibble the type, low nibble a size (15 = an integer object with the real size follows).
| Marker | Type | Marker | Type |
| 0x00 · 0x08 · 0x09 | null · false · true | 0x5n | ASCII string, n bytes |
| 0x1n | integer, 2n bytes BE | 0x6n | UTF-16BE string, n characters |
| 0x2n | real, 2n bytes | 0x8n | UID, n+1 bytes |
| 0x33 | date (float64 seconds since 2001) | 0xAn · 0xCn | array · set of n object references |
| 0x4n | data, n bytes | 0xDn | dictionary: n key refs, then n value refs |
The keyed-archive structure
{
"$archiver": "NSKeyedArchiver",
"$version": 100000,
"$top": { "IB.objectdata": UID(1) }, // "root" in most other archives
"$objects": [
"$null", // index 0 = nil
{ "$class": UID(5), "NSRoot": UID(2), "NSConnections": UID(9), … },
…
{ "$classname": "NSIBObjectData", "$classes": ["NSIBObjectData", "NSObject"] }
]
}
$objects is a flat array; objects refer to each other with UID values (indices into it). $null at index 0 stands for nil.
- Each archived object is a dictionary of its keys, plus
$class: a UID of a class dictionary with $classname and $classes (the class and its superclasses, so an unknown class can be decoded as a known ancestor).
- Strings and numbers are stored as plain plist values; arrays and dictionaries as objects with
NS.objects (and NS.keys).
$top names the root: for a nib, IB.objectdata → an NSIBObjectData with NSRoot, NSVisibleWindows, NSConnections and the object/name tables.
The tool converts both encodings to one model — a list of objects, each with a class and a list of (key, type, value) — so everything below applies to both.
8Important keys
The root object (iOS)
| Key | Contents |
| UINibTopLevelObjectsKey | The top-level objects returned by instantiateWithOwner:options:: the main views, view controllers, gesture recognizers. |
| UINibObjectsKey | Every object in the nib. |
| UINibConnectionsKey | The outlet and action connections (below). |
| UINibVisibleWindowsKey | Windows to show on load. |
| UINibAccessibilityConfigurationsKey | Accessibility settings applied after loading. |
| UINibKeyValuePairsKey | User Defined Runtime Attributes: key paths set with setValue:forKeyPath: on objects after loading. |
Objects
| Key | Meaning |
| UISubviews · NSSubviews | The view's children (an array): the view hierarchy. UISuperview points back. |
| UIClassName · UIOriginalClassName | On a UIClassSwapper: the custom class set in Interface Builder (LoginButton, _TtC5MyApp9PinView) and the UIKit class it stands in for. |
| UIProxiedObjectIdentifier | On a UIProxyObject: a placeholder for an object that is not in the nib — IBFilesOwner (the owner passed at load, usually the view controller) or IBFirstResponder. |
| UIText · UITitle · UIPlaceholder | Text of labels, text fields, buttons. |
| UIHidden · UIAlpha · UIOpaque | Visibility. |
| UIBounds · UICenter · UIFrame | Geometry. |
| UITag · UIRestorationIdentifier | Integer tag; identifier for state restoration. |
| UIAccessibilityLabel | The VoiceOver label, when stored on the object. |
| NSTitle · NSContents · NSToolTip · NSWindowTitle | The macOS counterparts. |
9Outlet and action connections
Connections are how a nib is wired to code. After unarchiving, UIKit runs each connection object's connect:
| Class | Keys | Effect |
| UIRuntimeOutletConnection | UILabel, UISource, UIDestination | Outlet: [source setValue:destination forKey:label] — e.g. the File's Owner's passwordField property is set to a text field. |
| UIRuntimeOutletCollectionConnection | UILabel, UISource, UIDestination | An outlet collection (an array property). |
| UIRuntimeEventConnection | UILabel, UISource, UIDestination, UIEventMask | Action: [source addTarget:destination action:@selector(label) forControlEvents:mask] — e.g. a button sends loginTapped: to the view controller on touch-up-inside. |
| NSNibOutletConnector · NSNibControlConnector | NSLabel, NSSource, NSDestination | macOS outlet and target/action. |
| NSNibBindingConnector | NSBinding, NSKeyPath, … | macOS Cocoa binding: a property bound to a key path. |
The destination of an action, and the source of an outlet, is often the IBFilesOwner proxy, i.e. the view controller. The action's selector is the name of the method to read next: find it in the Mach-O tool's class browser (-[LoginViewController loginTapped:]).
10Security relevance
A nib is data the app trusts completely, and nobody reviews it like code. Things worth looking for:
- Hidden views and controls (
UIHidden true, UIAlpha 0, zero-size frames): debug menus, environment switchers, "skip login" or admin buttons that code un-hides under some condition. Find the outlet that points at them and the code that touches it.
- Hard-coded strings: default text and placeholders with test accounts, URLs (support, API, staging hosts), keys in User Defined Runtime Attributes, prefilled values of text fields.
- Accessibility labels and identifiers often describe a control's real purpose more plainly than its title, and make UI automation (and therefore tampering scripts) easy.
- Custom classes (
UIClassName) tell you which classes implement a screen — the entry point for reversing it. Swift classes appear with mangled names.
- Actions and outlets map buttons to the methods that handle them: the fastest way from "the PIN screen" to the code that checks the PIN.
- Text-input traits of sensitive fields (secure entry, autocorrection, keyboard type), which affect what the system keyboard caches.
A nib cannot run code by itself, but unarchiving instantiates arbitrary classes and sets arbitrary key paths. An app that loads nibs (or other keyed archives) from an untrusted source — downloaded, or from a writable location — is an object-injection risk; keyed archives should be decoded with NSSecureCoding and an allow-list of classes.
11What the tool shows, and its limits
- Overview: the encoding (NIBArchive with its format and coder versions, or NSKeyedArchiver with its version), object, key, value and class counts, the classes by number of instances, and the top-level objects (
UINibTopLevelObjectsKey, or NSRoot and NSVisibleWindows on macOS).
- Connections: every object whose class ends in
Connection or Connector, as outlet, action, binding, help (tooltips) or accessibility, with its name, source and destination; filterable.
- View hierarchy: trees built from
UISubviews / NSSubviews (and a window's content view), each view with its class and a label taken from its text, title, class name, identifier or accessibility label.
- Strings: every string object and string or text-like data value, with the object and key it belongs to.
- Objects: the whole object graph from the root, expandable; a reference back to an object already open above is marked ↻. inspect links open any object at the top.
The tool reads one nib file at a time: open the individual .nib files inside a .storyboardc or a nib folder, not the folder. It shows the archived keys and values as they are; it doesn't render the interface, decode geometry or colours from their packed data values, or follow layout constraints.
12The NIB library
The parser is lib/nib.js, a JavaScript module with no user interface. It exports the class NibArchive; keyed-archive nibs are binary plists, which it reads with lib/plist.js (imported by the module itself).
import { NibArchive } from "../lib/nib.js";
| Method / property | What it does |
| NibArchive.parse(input) | An ArrayBuffer or Uint8Array → a NibArchive, from either encoding. Throws with a sentence when the file is not a compiled nib (and says so for an XML .xib or .storyboard). |
| archive.format, version, objects, root, counts | format is "NIBArchive" or "NSKeyedArchiver", root the index of the root object, counts is { objects, keys, values, classes } (keys and values are null for keyed archives). |
| object | { className, values }; keyed archives also mark isNil ($null), isClassDescription (a $classname record) and primitive (a bare string or number). |
| value | { key, type, value }; type is "int", "float", "bool", "nil", "data" (a Uint8Array), "str", "obj" (an object index) or "arr" (a list of values). A collection's items have the key UINibEncoderEmptyKey. |
| archive.stringOf(index) | The text of a string object (NSString, NSLocalizableString…), or null. |
| archive.valueString(value) | The text a value holds directly, through a string object, or as UTF-8 data; or null. |
| archive.itemsOf(index) | The item values of an NSArray, NSSet, NSOrderedSet or NSDictionary, or null. |
| archive.topLevelObjects() | The indexes of the top-level objects (see above). |
| archive.connections() | [{ index, kind, className, label, source, destination, extra }]: kind is "outlet", "action", "binding", "help", "accessibility" or "other"; source and destination are values (usually "obj"). |
| archive.viewHierarchy() | { children: Map(index → [child index]), roots } from the subviews and window content views. |
| archive.strings() | [{ text, where, owner }]: every string, with "Class.key" and the index of the object it belongs to. |
| NibArchive.detect(input) | "NIBArchive", "keyed", "xml" or null, from the first bytes. |
| NibArchive.valueFor(object, key) | The object's first value with that key, or null. |
| NibArchive.dataText(bytes) | The bytes as text when they are printable UTF-8, otherwise null. |
import { NibArchive } from "../lib/nib.js";
const archive = NibArchive.parse(bytes);
for (const connection of archive.connections()) {
const target = archive.objects[connection.destination.value];
console.log(connection.kind, connection.label, "→", target.className);
}
console.log(archive.strings().map((item) => item.text));