Could not load NIB in bundle

180,778

Solution 1

Visit the properties of the .xib files in the file inspector,the property "Target Membership" pitch on the select box, then your xib file was linked with your target

Solution 2

In Targets -> Build Phases

Make sure the .xib is added to Copy Bundle Resources, if it is not present then add .xib file.

Solution 3

try to find out all

XXXController = [[XXXControlloer alloc] initWithNibName:@"XXXController" bundle:nil];

in your code, and make sure that XXXController are spelled correctly

Solution 4

I had the same problem (exception 'Could not load NIB in bundle: ..') after upgrading my xcode from 3.2 to 4.02. Whereas deploying of my app with Xcode 3.2 worked fine it crashes with xcode 4 raising the exception mentioned above - but only when I tried to deploy to the IOS Simulator (v.4.2). Targeting the IOS device (v.4.1) acted also with Xcode 4.

It turned out (after hours of desperately scrabbling around) that the reason was an almost "hidden" setting in the .xib-file:

Visit the properties of the .xib files in the file inspector: The property 'Location' was set to 'Relative to Group' for all .xib files. I changed it to 'Relative to project' and voila: all .xib files now are correctly loaded in IOS simulator !

I have no clue what's the reason behind that for this odd Xcode4 behavior but maybe it's worth to make an attempt ?

Solution 5

In my case it was very weird (use a storyboard): For some reason it changed from "Main storyboard file base name" to "Main nib file base name" in the plist.

Changing back to "Main storyboard file base name" (UIMainStoryboardFile) solved the issue

Share:
180,778
Goje87
Author by

Goje87

Updated on July 13, 2021

Comments

  • Goje87
    Goje87 almost 3 years

    I am trying to integrate Janrain Engage as custom module with Appcelerator Titanium. I have created a sample module and dragged the JREngage folder to the sample module xcodeproj as indicated in the Jainrain's documentation.

    Now I give build command to this project, then execute the ./build.py and then finally I execute the titanium run command. It launches the application in simulator with a blank screen and immediately crashes throwing the following error.

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/abhilash/Library/Application Support/iPhone Simulator/4.2/Applications/CA167346-4091-4E16-B841-955D1D391713/test.app> (loaded)' with name 'JRProvidersController''

    Why could this error be occurring?

  • Goje87
    Goje87 about 13 years
    Hey Hanuman, I have checked that file JRProvidersController.xib exists. I have also tried to rename the file and execute, even then it's throwing the same exception.
  • Hanuman
    Hanuman about 13 years
    try changing the invocation to initWithNibName:NSStringFromClass([MyViewController class]). Also check closely for file name as it is case sensitive
  • Hanuman
    Hanuman about 13 years
  • Goje87
    Goje87 about 13 years
    I have made the changes suggested by you, but have got no success.
  • Robert Childan
    Robert Childan about 12 years
    Additionally, if you are using alloc init, instead of initWithNibName:bunle:, what you will get is a black screen.
  • Nir Pengas
    Nir Pengas about 12 years
    same thing here as michael is describing. i had created a xib file holding a custom UITableViewCell. when i open the .app and searched for myCell.xib, i see it's actually myCell.nib. further more, the app was only crashing on the device and load the xib file okay when executing on the simulator. it was a bit tricky to reset it. for me at least. only when i deleted the file, cleaned the target and copied the file back - did it work.
  • Ben
    Ben over 11 years
    Wondering why an absolutely unused .xib file must hang in a project file folder…
  • Yunus Nedim Mehel
    Yunus Nedim Mehel over 11 years
    I guess I accidentally unchecked this checkbox instead of autolayout. Fixed the crash for me, thanks
  • Pieter Jongsma
    Pieter Jongsma almost 11 years
    The reason you mustn't add the extension is that in your compiled bundle, .xib files are also compiled into .nib files. So there actually wasn't a MyFile.xib in your bundle, nevermind the double extension.
  • chings228
    chings228 over 10 years
    it's easy , since the nibname is not autotyped
  • Rameez Hussain
    Rameez Hussain about 10 years
    Good one. Had the same problem. Thanks. This solved it.
  • BeccaP
    BeccaP over 9 years
    This solved my problem! Thank you. I had just duplicated my project and renamed all the pertinent files. Everything worked but this. Now everything works!!
  • Peter Kazazes
    Peter Kazazes over 9 years
    This solved a crash I was dealing with when compiling a very out of date Quartz Composer plugin.
  • fotisgpap
    fotisgpap over 9 years
    marked up as it also shows an easy way to find and view the package contents
  • i89
    i89 over 8 years
    This solved my problem, since I got two storyboards "MyStoryboard.storyboard" and "MyStoryboard~ipad.storyboad"...so from the iPad target I removed "MyStoryboard.storyboard" from the "Copy Bundle Resources"
  • Gil Sand
    Gil Sand almost 8 years
    He meant the class name in just before the alloc, which is autotyped :P
  • Stas
    Stas almost 8 years
    all target membership checkboxes are grayed out for me...what could be the reason?
  • Kyle Goslan
    Kyle Goslan almost 8 years
    I just deleted Derived Data folder and it worked. Seems to get confused because I had renamed the xib file in the project navigation. Odd one.
  • Vyachaslav Gerchicov
    Vyachaslav Gerchicov about 7 years
    uiview could be loaded from nib but doesn't have initWithNibName:bundle: method
  • chings228
    chings228 about 7 years
    we are talking about viewcontroller
  • Zaporozhchenko Oleksandr
    Zaporozhchenko Oleksandr over 5 years
    @chings228 XXXControlloer and XXXController, see the difference
  • heximal
    heximal about 5 years
    doh. how could I get myself to this again. thanks kind man:) i was at very beginning of the researching this problem
  • SafeFastExpressive
    SafeFastExpressive about 4 years
    File name for my nib was FormItemCheckBoxCell.nib, class was FormItemCheckboxCell. Capitalizing "Box" in the name cost 45 minutes of my life.
  • Firda Sahidi
    Firda Sahidi almost 4 years
    Finally! I work in modular project of iOS and this is what I'm looking for. Thank you!
  • famfamfam
    famfamfam almost 4 years
    what is aViewInMyCustomView?
  • norbDEV
    norbDEV over 3 years
    @famfamfam: a UIView
  • famfamfam
    famfamfam over 3 years
    tks, now i know how to use
  • jpb
    jpb over 3 years
    Similarly, I got an error like this when I (foolishly) tried to assign a table view delegate and data source in the init() rather than viewDidLoad()
  • Pravalika
    Pravalika over 3 years
    I had an extra character in my .xib file name. If I didn't come across your answer, I might have never figured it out. Thanks a lot.
  • LMaker
    LMaker over 2 years
    can you show how you did?