NSInternalInconsistencyException, reason: Failed to load the NIB bundled

I went through a bunch of answers to this problem, but none of them are related to my problem.

I have two views, View 1 has a button. In view mode 2 there is a button.

The View 1 button is attached to the segue model for viewing 2.

I press the button in view 1, the 2nd view opens.

In view 2, the button is connected to IBAction, which launches

[self dismissViewControllerAnimated:YES completion:nil]; 

Which closes the View and displays View 1 again - Now, if I press the Button on View 1 button again, I will get

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <x/y/z/SomeApp.app> (loaded)' with name 'tvz-Io-ndz-view-rB8-bq-l6j' and directory 'Main.storyboardc'' 

I completely lost the solution to this problem. Please, help!

EDIT:

  • This only happens when the device does not have internet.
  • If I have a third screen in a chain with a webview that displays an image, if I go to this screen from View 2, the application will not work.

EDIT 2:

I also tried to restore the screen from scratch.

I am completely puzzled.

EDIT 3: Complete Stacktrace

 2015-01-19 09:10:58.528 SomeApp[37747:2203364] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/user/Library/Developer/CoreSimulator/Devices/D23C1B7C-7330- 466E-8369-762C6727B19C/data/Containers/Bundle/Application/AE67C3D3-C5AE- 4A66-91EC-54D976A4A4FC/SomeApp.app> (loaded)' with name 'tvz-Io-ndz-view- rB8-bq-l6j' and directory 'Main.storyboardc'' *** First throw call stack: ( 0 CoreFoundation 0x01f64946 __exceptionPreprocess + 182 1 libobjc.A.dylib 0x01beda97 objc_exception_throw + 44 2 CoreFoundation 0x01f6486d +[NSException raise:format:] + 141 3 UIKit 0x008f8e06 -[UINib instantiateWithOwner:options:] + 1003 4 UIKit 0x0071b624 -[UIViewController _loadViewFromNibNamed:bundle:] + 270 5 UIKit 0x0071bdbb -[UIViewController loadView] + 295 6 UIKit 0x0071bfef -[UIViewController loadViewIfRequired] + 78 7 UIKit 0x0071c595 -[UIViewController view] + 35 8 UIKit 0x00d8f707 -[_UIFullscreenPresentationController _setPresentedViewController:] + 75 9 UIKit 0x006f1a81 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 113 10 UIKit 0x00729a61 -[UIViewController _presentViewController:withAnimationController:completion:] + 2102 11 UIKit 0x0072c5d2 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 345 12 UIKit 0x0072c424 -[UIViewController presentViewController:animated:completion:] + 224 13 UIKit 0x0072c8ea -[UIViewController presentModalViewController:animated:] + 57 14 UIKit 0x00bf448d -[UIStoryboardModalSegue perform] + 271 15 UIKit 0x00be1b49 -[UIStoryboardSegueTemplate _perform:] + 217 16 UIKit 0x00be1bc5 -[UIStoryboardSegueTemplate perform:] + 116 17 UIKit 0x006d4907 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1490 18 UIKit 0x006d4af7 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 285 19 UIKit 0x006d9df3 __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43 20 UIKit 0x005ee0ce ___afterCACommitHandler_block_invoke + 15 21 UIKit 0x005ee079 _applyBlockToCFArrayCopiedToStack + 415 22 UIKit 0x005ede8e _afterCACommitHandler + 545 23 CoreFoundation 0x01e879de __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 24 CoreFoundation 0x01e87920 __CFRunLoopDoObservers + 400 25 CoreFoundation 0x01e7d35a __CFRunLoopRun + 1226 26 CoreFoundation 0x01e7cbcb CFRunLoopRunSpecific + 443 27 CoreFoundation 0x01e7c9fb CFRunLoopRunInMode + 123 28 GraphicsServices 0x043d524f GSEventRunModal + 192 29 GraphicsServices 0x043d508c GSEventRun + 104 30 UIKit 0x005c48b6 UIApplicationMain + 1526 31 SomeApp 0x000e482d main + 141 32 libdyld.dylib 0x027e8ac9 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException 

James

+8
source share
8 answers

There are many reasons that can cause the error you receive.

I will begin to list some things to check and solve:

  • Did you rename your xib or storyboard file outside of Xcode? If so, check wherever you have a link to it for inconsistencies. Also, make sure you respect uppercase and lowercase letters wherever you refer to the file, as it is case sensitive.

  • Go to Interface Builder, select View1 ViewController> Utility Panel> Identity Inspector > check if the Custom Class matches your ViewController class if you have one (.h and .m files).

  • Check the Info.plist file. If you use storyboads, you should have an entry of type Main storyboard file base name and NOT Main nib file base name . If you use tips, then it's the other way around. Also check that the base file name matches the name of the actual file.

  • Check your Build Phases > Copy Bundle Resources target and make sure the xib or storyboard file is added there.

  • If you programmatically create a View1 ViewController and use an xib file, check the nib name for typos (remember, case sensitive). Also, if you are currently adding the .xib file format to the name, remove the extension because it should not be used. I mean this line of code: UIViewController *controller = [[UIViewController alloc] initWithNibName:@"xibFileName" bundle:nil];

  • Check the properties of the xib file or storyboard in the file inspector and make sure your file is linked to your target in the Target Membership selection panel.

  • Check the properties of the xib file or storyboard in the file inspector and try switching the Location file to Relative to project or Relative to group . See if there is any way.

  • If you add your view controller programmatically to initWithCoder , then you must instantiate it in the viewDidLoad method

  • If none of the above applies to your situation, you can remove the file from Xcode (select Remove References ) and import it again into your project.

Remember to ALWAYS clean the project after making the specified changes (SHIFT + COMMAND + K).

Please tell us if this worked and what worked.

+30
source

I tried all the above, but they did not work. For me, the solution was to include xib in the target resource.

Completed steps:

  • Click on the xib file.
  • Open an identity inspector → Target membership and check the second option (ProjectName_Resource)
+2
source

You may need to configure the package for the class before accessing xib:

ObjectiveC:

 //Bundle initialisation NSBundle* bundle = [NSBundle bundleForClass:[self class]]; //Initialising the nib UIView *nibView = [[bundle loadNibNamed:@"nibFileName" owner:self options:nil] objectAtIndex:0]; //Display the ad (this will vary based on your application setup) [[[UIApplication sharedApplication] keyWindow] addSubview:nibView]; 
+1
source

I came across this when I extracted .app from a zip file and tried to run it on both an iOS device and Simulator.

One .nib file was called non-Latin characters ( fileNormal.nib with Greek letters No ), and when extracted from zip it was assigned letters from a different encoding (it must be Greek-DOS or something compatible). I chose a different encoding during extraction, and it worked as it should.

Just put this in case someone else is facing the same problem;)

+1
source

You can try and check the scripts below for an exception:

1) If the nib file is missing, add it to your Xcode

2) Before rejecting, put a check inside the IBAction method, open this

0
source

It is also possible that a UITableViewDataSource or UITableViewDelegate is not implemented in the desired UIViewController

0
source

If you work with cocoapods, this can also help run pod update . One of my teammates changed the block that caused the error, so the pod update was fixed for me.

0
source

In my case, the exact same exception was caused by the fact that two controllers had the same storyboard identifier (within the same storyboard)

0
source

Source: https://habr.com/ru/post/980706/


All Articles