Could not load nib in bundle on iPhone device
I'm trying to test an app I'm developing on my iPhone. To do that I changed the target from Simulator to Device on Xcode. The application is correctly uploaded to the device and it works. The main view is shown but if I try to open a secondary view, the application crashes.
On the iPhone log (I installed the iPhone configuration utility to see the console [is the only way to see the log from iPhone?]) I can see this error:
Could not load NIB in bundle
But, on the simulator it works fine. What's wrong? Any ideas?
I had the same problem and fixed it like so:
- Open XCode Target
- Click the "Build phases" tab
- Click the "Copy bundle resources" section
- Click the +
- Add the missing Nib file
I've found that sometimes the device is case sensitive and the simulator is not.
What's the filename of your xib?
or
Try uninstalling the app from the simulator and installing it again - the simulator might have an old file left over from a previous run of the app - have you renamed / moved the xib at all during development?
I had a similar problem and was getting the same error. Turns out I was using the full name of the xib file in the attributes panel under "NIB Name:"
Don't use "SomeViewController.xib", just use "SomeViewController" without the ".xib" extension.
I had the same problem when invoking initWithNibName:@"MyViewController"
Changing the invocation to initWithNibName:NSStringFromClass([MyViewController class])
worked well
You can try these things:
- Make sure case is correct
- Use xib filename without the ".xib" extension
- Remove any -(dash) or other special chars, use _(underscore)
- Remove the xib file from the project and add back to the Xcode project
- Check the build settings and make sure deployment is changed to currect SDK