What is the difference between NIB and XIB Interface Builder file formats?

CocoaInterface Builder

Cocoa Problem Overview


What is difference between nib and xib in Interface Builder files?

Cocoa Solutions


Solution 1 - Cocoa

>As of Interface Builder version 3, a new file format (with extension .xib) has been added, which is functionally identical to .nib, except it is stored in a flat file, making it more suitable for storage in revision control systems and processing by tools such as diff.

http://en.wikipedia.org/wiki/Interface_Builder#Design

Solution 2 - Cocoa

The XIB File is basicly a source document of a NIB File, XIBs can nearly always be edited in Xcode (unless they are outdated or corrupt). while the newer NIBs are compressed and are unopenable, The older NIBs are bundles which can be viewed by Xcode, The Bundled NIBs contain some source/archived files which includes designable.nib which is often just the renamed XIB File.


> NIB = Nxt Interface Builder (NXT = NextStep = NS) > > XIB = Xml Interface Builder


Although the new archived NIB files are unopenable to most applications including Xcode, they can still potentially be unarchived. I found this freeware application called NibUnlocker On The CharlesSoft Website which can potentially disassemble a flat Nib file and export it as an XIB document. This application is still fairly buggy but it is sometimes very accurate based on the Nibs contents.

(NibUnlocker is a very inaccurate name, Nibs are not locked they are archived)


Click to Download NibUnlocker


If You wish to know a bit more you can read some additional information I have provided below in regards to the NIB and XIB Formats:

> Nxt Interface Builder Anatomy: > > Flat NIBs > > A Flat NIB file is complicated file to analyse but this is not impossible. The structure of these files is just an apple binary property list (begins with "bplist00") and some of its contents are archived through NSKeyedArchiver. Since a NIB is formatted as a property list, This allows a small hack: if you actually change the extension of a flat Nib to .plist, eg. ArchivedNib.nib to ArchivedNib.plist You will actually be able to open it in Xcode viewing it as a Property List although not all of the values will be shown because Xcode doesn't know how to display some values (CFKeyedArchiverUID values). When you view a Nib as a property list you will probably get a few base properties such as $version, $objects, $archiver and $top. > > Useful Notes > > A CFKeyedArchiverUID object is simply a redirector, in the {value = xx}, the value is an index for a item in the $objects array (from the start of the array). eg. <CFKeyedArchiverUID 0x60800002bc20 [0x7fffef6b8c30]>{value = 29}, value = 29, the result would be the 29th item in the $object's array (Just Remember the array starts with 0). In Objective C you can retrieve this value from a CFKeyedArchiverUID with this method : >

+ (NSUInteger)valueForKeyedArchiverUID:(id)keyedArchiverUID {
  void *uid = (__bridge void*)keyedArchiverUID;
  NSUInteger *valuePtr = uid+16;
  return *valuePtr;}

> (I found this out myself using the internet and later I used Hopper to disassemble NibUnlocker and I noticed in its source code, it uses the same technique by loading the NIB into an NSDictionary and going through all its connections, objects, etc.. and writes out a new XIB)

yo hit me up with an upvote if this helped ;-)

Solution 3 - Cocoa

XIBs are flat files rather than being a bundle. This makes it easier for SCM(source control management) systems to deal with. When you compile your app, the XIB is compiled into a NIB file for inclusion in your app.

The compiled NIB that is included in the app bundle is no longer editable in Interface Builder and is much smaller than the equivalent XIB or legacy NIB file.

Solution 4 - Cocoa

Also when you compile your project, .xib file will get compiled into nib.

Solution 5 - Cocoa

Functionally nothing but the xib is a source control friendly format

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRatanView Question on Stackoverflow
Solution 1 - CocoaDelan AzabaniView Answer on Stackoverflow
Solution 2 - CocoaYeaTheMansView Answer on Stackoverflow
Solution 3 - CocoakarthikPrabhu AlaguView Answer on Stackoverflow
Solution 4 - CocoaVojtoView Answer on Stackoverflow
Solution 5 - CocoaKevinView Answer on Stackoverflow