Have you ever gotten a message from the compiler that reads:
“Could not load NIB in bundle”? The error message looks similar to the below snippet:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <filepath> (loaded)' with name 'CustomViewController''
Sometimes, you think you’ve done everything right – here are different ways I’ve tried to solve this problem that have worked in the past for me.
While in your app in Xcode, go to Product > Clean (or command + shift + K)
Hold down your app’s icon and click the ‘X’ button Build + run your app from Xcode again
In the Project Navigator (left-most pane), click on your project – it should be the file with the blue icon next to it In the panel that appears, under TARGETS, click on your project, then click ‘Build Phases’ from the top menu Click on arrow next to Copy Bundle Resources. Add your .xib file to that list if you do not see it there, or drag it in from your Project Navigator.
This one is easy to overlook, but make sure you have named your xibs correctly For example, “CustomViewController.xib” is not the same as “CstomViewController”
I am currently trying to compile different ways to solve this error – if you have any other solutions, please comment below!
Last tested in Xcode 8.0