Abdullah Shafique Abdullah Shafique - 9 days ago 5
Objective-C Question

Unable to load nib file: MainWindowController.xib, exiting

I just created my first Mac Application but the program keeps crashing with this message:

Unable to load nib file: MainWindowController.xib, exiting


All I did was delete MainMenu.xib and created MainWindowController.xib and added it as the MainInterface.

enter image description here

Answer

This error is caused by the nib/xib missing at runtime when NSApplication tries to load what it is told is the main interface nib. In most cases it stems from accidentally removing the nib from the "Copy Bundle Resources" build phase for your application target. For other (non main nibs) it can also be caused by typos when typing the nib name.

In this specific case, however, I have determined that selecting the "main interface" from the dropdown menu in the target properties section is bugged. You have to delete the ".xib" extension from it for it to work correctly; so manually type MainWindowController instead of the MainWindowController.xib that you selected.

With the ".xib" extension in the "Main Interface" box, NSApplication will erroneously attempt to load MainWindowController.xib.xib