Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load NIB in bundle: 'NSBundle'

Tags:

What is the error listed below?

2011-02-23 21:24:12.218 Success[7238:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (loaded)' with name 'MainWindow-iPad''

like image 436
James K. Avatar asked Feb 24 '11 02:02

James K.


People also ask

Could not load nib in bundle bundle?

It happens when you rename the nib file. If you have already, create new nib(meaning copy current nib file contents to new nib), delete old nib file and it will solve your problem.

How do I load a nib in Swift?

mainBundle(). loadNibNamed("SomeObject", owner: self, options: nil) self. addSubview(self. view); // adding the top level view to the view hierarchy } required init(coder aDecoder: NSCoder) { super.


2 Answers

One of your NIB file is missing from project, add the required NIB file:

In Build Phases

  1. expand Copy Bundle Resources
  2. click + at bottom
  3. add the required NIB file.

Clean your build by Shift+Cmd+K, then run.

P.S. Also make sure to use exact spelling of NIB file while calling initWithNibName:@"ViewNameController"

Probably, you have named your NIB in a call by lowercase letters or you may have also included extension .xib which is not required.

like image 162
Baig Avatar answered Sep 20 '22 19:09

Baig


Probably, you have named your NIB in a call by lowercase letters. The simulator works fine in this case, but an iPhone device will return an error during runtime.

For example,

DetailViewController *detailViewController = [[DetailViewController alloc]             initWithNibName:@"detailViewController" bundle:nil]; 

will fail. You need to change to:

DetailViewController *detailViewController = [[DetailViewController alloc]             initWithNibName:@"DetailViewController" bundle:nil]; 
like image 45
Denis Kutlubaev Avatar answered Sep 21 '22 19:09

Denis Kutlubaev