Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 888
Ratan Avatar asked Sep 16 '10 11:09

Ratan


People also ask

What is the difference between NIB and XIB?

NIBs and XIBs are effectively the same thing: XIBs are newer and are used while you're developing, whereas NIBs are what get produced when you create a build. In modern versions of iOS and macOS, NIBs and XIBs have effectively been replaced by storyboards, although you may still meet them if you work on older projects.

What is NIB file type?

A nib file is a special type of resource file that you use to store the user interfaces of iOS and Mac apps. A nib file is an Interface Builder document.

What is an XIB file?

What are XIB files? From the point of view of the UI designer, XIB files contain the views or windows that you design in Interface Builder – the controls, their layout and properties, and their connections to your code. It is important to understand that on a technical level, XIB files are stored object graphs.

Which is better storyboard or XIB?

In Storyboard using table cell is better then XIB because it gives more flexibility. In Storyboard it is not easy to handle if you have a large amount of code. It is useful only for a small amount of code.


2 Answers

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

like image 76
Delan Azabani Avatar answered Sep 17 '22 19:09

Delan Azabani


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 ;-)

like image 44
YeaTheMans Avatar answered Sep 17 '22 19:09

YeaTheMans