Objective-c – Could not load NIB in bundle

iphoneobjective cxcode

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

Best Answer

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