4

* 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.

4 Answers 4

11
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.
Sign up to request clarification or add additional context in comments.

4 Comments

It is called ViewLecturer.xib . Get info on the xib shows the file type as 'file.xib' (saw another post regarding this). The file is included in the app bundle in the 'copy bundle resources folder. Tried cleaning all targets and rebuilding in device but still receiving same error.
Thanks anyway, i rename the file to another name and change it back and worked fine. Some bug i guess.
+1 for the build phases comment. In the past I've only had one Target and have never run into this. But now I'm on a project with multiple Targets and for some reason none of them were checked when adding the file. Thanks!
I had the same error on a project that worked until I upgraded XCode. I stumbled on this exchange and tried the idea of renaming the XIB and renaming it back. I had to do it to both my XIBs (not just MainWindow) but it worked! Thanks, it was driving me crazy for a while. thanks @user755053
6

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...

Comments

2

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!

Comments

0

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

1 Comment

Checked nib name, it's is the same, case-sensitive.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.