16

I am getting the following error when I use my app for a little while. Usually takes between 50 and 100 movements to cause the crash. I am not making sense of it though as I am using storyboards, and it is a NIB error.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 
'Could not load NIB in bundle: 'NSBundle 
</Users/me/Library/Application Support/iPhone Simulator/5.0/Applications/GUID/appname.app>
(loaded)' with name 'MainStoryboard_iPhone.storyboardc/q8p-MH-tsT-view-acD-hJ-g0C''

I am not 100% sure where to begin looking, but I assume that this means that the storyboard is corrupt?

I looked through all of my source, and I don't have the string "nib" anywhere, so there are no nibWithNibName calls or the like. I also don't have a MainWindow.xib, though I tried creating one. I am not sure if it can be set to the main interface when I am using storyboards though. There is one reference to a .nib in the .xcodeproj/project.pbxproj file, however:

/* Begin PBXBuildRule section */
148BDD4C14AE8D5E002C30ED /* PBXBuildRule */ = {
    isa = PBXBuildRule;
    compilerSpec = com.apple.compilers.proxy.script;
    fileType = wrapper.nib;
    isEditable = 1;
    outputFiles = (
    );
    script = "$(DEVELOPER_BIN_DIR)/ibtool\n";
};

I am using storyboarding in Xcode 4.2. My main storyboard is set to MainStoryboard_iPhone, and its file is named MainStoryboard_iPhone.storyboard.

The crash is in the iOS 5 simulator.

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256
stubble jumper
  • 275
  • 1
  • 4
  • 10
  • 1
    Hello, welcome to SO. If you begin your paragraphs with a 4 space indent, it formats them as code. I have corrected this for you. – jrturton Dec 31 '11 at 16:40
  • 2
    With regards to your question, the storyboard will call loadnibnamed or similar in the background on your behalf when loading a new view. If you look at the identity inspector in the storyboard you will see a field called object ID - one of these should match part of the string you are seeing in your error (q8p...). This should narrow down what it is trying to load. – jrturton Dec 31 '11 at 16:45
  • If you open the storyboard as source code, you can search for it directly. – jrturton Dec 31 '11 at 16:46
  • Thanks for the pointers. I think I have this one wrapped, though I need many hrs of qa to be convinced. I think what was happening is that there was a memory leak, and when resources were exhausted, it would choke and not be able to load the NIB in above. – stubble jumper Jan 01 '12 at 02:09
  • 1
    Just adding that this is what it was. There was a memory leak in a 3rd party component. Once the resources were exhausted, it would crash with the error above. A couple weeks of QA/Beta testing confirmed that it is gone. Thanks. – stubble jumper Jan 24 '12 at 02:29
  • 2
    This question is still open, as you have found the solution you may want to answer it. :) – jackslash Feb 28 '12 at 21:03
  • Concur with @jackslash - Stubble jumper, add your comment as a new answer, and accept it please (this all helps SO work correctly). – Scott Corscadden Apr 23 '12 at 12:23
  • Can you please tell how did you solve this issue? – Umang Kothari Jul 04 '16 at 13:23

3 Answers3

43

I got exactly this error, too.

Finally I found the cause was I accessed self.tableView in -(id)initWithCoder:(NSCoder *)aDecoder before it was initiated.

So, I moved those code into - (void)viewDidLoad, everything went well.

DaiZW
  • 531
  • 4
  • 6
  • It's so strange, it used to work, but then I did some magic while changing nothing, and it started to crash, and your solution is right! thanks! – dreamzor Mar 27 '13 at 19:40
  • 3
    In order to understand storyboard flow, there are a couple of rules: 1. do not perform any UI setup in init functions (eg: initWithCoder); 2. perform UI setup in either viewDidLoad or viewWillAppear; 3. understand initialization steps: initializeViewControllerWithIdentifier -> viewDidLoad -> (in case you performed any further manipulation in parent view controller, it will override viewDidLoad) -> viewWillAppear -> viewDidAppear. – morph85 Dec 13 '13 at 07:05
  • Thanks DaiZW, you saved the day! Like dreamzor mine started crashing without any changes from me. Be aware tho'; my offending initialise code in initWithCoder: was NOT UI related, only assigning a singleton model object. Incidentally, it may help to isolate the source of the problem to know the then 'name' might refer to more than one object; my '78L-th-1kK-view-ZbE-ni-SzJ' referred to TableVC '78L-th-1kK', TableView 'ZbE-ni-SzJ' – cate Feb 11 '14 at 19:10
2

This question appears to have been answered in the comments area. Reposting here so question shows as having an answer. -- gs.

Answer copied from comments:

There was a memory leak in a 3rd party component. Once the resources were exhausted, it would crash with the error above. A couple weeks of QA/Beta testing confirmed that it is gone. Thanks. – stubble jumper Jan 24 at 2:29

Greg Steiner
  • 647
  • 1
  • 9
  • 20
  • You should really mark this as community wiki - you're doing the right thing, but any upvotes you get aren't really yours. – jrturton May 25 '12 at 18:42
  • Good point. Not sure how to do that exactly. If you can point me in the right direction I can make that change. – Greg Steiner Jun 01 '12 at 20:04
0

I've had this problem before. The name of my nib was different than the name of my view controller while using - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil as my init.

abriggs
  • 744
  • 7
  • 16