nibarchive 0.1.0

NIB Archive decoder/encoder
Documentation
  • Coverage
  • 75%
    30 out of 40 items documented1 out of 23 items with examples
  • Size
  • Source code size: 42.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • michaelwright235/nibarchive
    6 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • michaelwright235

NIB Archive Decoder/Encoder

Decode and encode NIB Archive .nib files.

.nib files are mainly used by Interface Builder component of Xcode to encode .xib files. Both store information about creating a GUI for macOS and iOS applications. The difference is, .xib is a human-readable xml used only during development, and .nib is a compiled version of it.

There're two variations of .nibs. The first one is a NIB Archive (used by UIKit on iPhones since iOS 6) whose decoded structure somewhat resembles Cocoa Keyed Archive. This library is designed to work with these .nibs. The second one is actually a Cocoa Keyed Archive (used prior iOS 6). macOS uses both versions.

The file format has been described in detail in the nibsqueeze repository and this great article. You may also want to check the nibarchive repository – a NIB Archive parser written in Python.

Known issues

Some NIB Archives (presumably ones with a coder version of 10) have some extra bytes at the end of a file. Those bytes are not handled and their purpose is unknown yet.

Example

The following example prints all archive's objects and their values:

use nibarchive::*;

let archive: NIBArchive = NIBArchive::from_file("./foo.nib")?;

for (i, object) in 0..archive.objects().iter().enumerate() {
    let class_name = object.class_name(&archive.class_names()).name();
    println!("[{i}] Object of a class '{class_name}':");

    let values: &[Value] = object.values(&archive.values());
    for (j, value) in 0..values.iter().enumerate() {
        let key = value.key(&archive.keys());
        let inner_value = value.value();
        println!("-- [{j}] {key}: {inner_value:?}");
    }
}