Tim
Tim

Reputation: 127

Could not load NIB in bundle

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewLecturer'

ViewLecturer *viewLecturer = [[ViewLecturer alloc]initWithNibName:@"ViewLecturer" bundle:nil];

[self.navigationController pushViewController:viewLecturer animated:YES];

I've check the file type and it's file.xib.
Doubled check the xib name is ViewLecturer but i still constantly get the error on the device. Works fine on the stimulator though.

Upvotes: 4

Views: 16620

Answers (4)

Liam
Liam

Reputation: 8102

Just found another reason for this. Normally when you add a new file to the project xcode will automatically add it to the "Copy Bundle resources" section of your target.

Sometimes, if you are collaborating with another person the project.pbxproj will get out of sync and this entry will get removed. The fix is to ensure that all the files in the Resources folder (that are required in the release) are also present in the "Copy Bundle resources" section, and if it isn't just drag it from the resources to that section.

Enjoy!

Upvotes: 2

visakh7
visakh7

Reputation: 26400

Make sure you use the correct file names, iOS is case sensitive, simulator is not. so if it works in simulator but not on device check the cases on the file name...

Upvotes: 6

user756245
user756245

Reputation:

ViewLecturer *viewLecturer = [[ViewLecturer alloc]
                              initWithNibName:@"ViewLecturer" bundle:nil];

You have to take care of two things :

  1. this call assumes you have a file named 'ViewLecturer.xib' and not 'file.xib'
  2. make sure the file is included in the app bundle. Check that in the build phases > copy ressources to bundle.

Upvotes: 11

Tendulkar
Tendulkar

Reputation: 5540

This issue is regarding the nibname .Check the nib name .

Upvotes: 0

Related Questions