Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode is attempting to load a NIB file that I deleted from the project

I started working on a view with a NIB file and decided to delete it from my project to build it programatically. There are no mentions of the supposed call to the NIB file in any of my code and the .XIB doesn't exist anywhere in any of the application directories. Here's the exact error being thrown at me from the debug console.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:      
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "GESplitMainViewController"
nib but the view outlet was not set.' 

I cannot comprehend why the xcode is still attempting to load the NIB.

like image 333
Rehat Kathuria Avatar asked Oct 05 '12 09:10

Rehat Kathuria


Video Answer


1 Answers

Firstly, the default implementation of initWithNibName:bundle searches the bundle for a nib that shares the same name as the view controller's class if you pass nil as the first parameter, which is why your app is trying to load one.

The fact that it is finding one is probably because the .xib you used to have in your project is still included in the bundle that the simulator is running. Xcode has a habit of leaving deleted resources in the simulator bundle even if you delete them from your project.

If you delete the app from the simulator, clean your Xcode project and run again, it should stop trying to load the nib.

Although this is the reason your app is loading from a nib, it is not the reason it is crashing. The crash is because the old .xib you were using didn't have a view connected to the view controller's view outlet.

like image 163
Adam Swinden Avatar answered Nov 15 '22 03:11

Adam Swinden