Failed to load bundled NIB

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

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

The application terminated due to the unannounced exception "NSInternalInconsistencyException", reason: "Failed to load the NIB in the package:" NSBundle </ Users / abhilash / Library / Application Support / iPhone Simulator / 4.2 / Applications / CA167346-4091-4E16- B841-955D1D391713 /test.app> (loaded) 'named' JRProvidersController ''

Why can this error occur?

+92
ios iphone xcode ios4 titanium appcelerator janrain
Mar 17 '11 at 9:44
source share
31 answers
  • one
  • 2

Visit the properties of the .xib files in the file inspector, the "Target Membership" step in the selection box, then your xib file was associated with your target

+194
Mar 07 2018-12-12T00:
source share

In Targets → Build Phases

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

+44
Nov 05 '12 at 13:05
source share

try to find out everything

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

in your code and make sure XXXController is spelled correctly

+22
Jul 23 '12 at 8:12
source share

I had the same problem (exception "Failed to load the NIB bundled: ..") after updating my xcode from 3.2 to 4.02. While deploying my application with Xcode 3.2 worked fine, it crashes with xcode 4, throwing the exception mentioned above, but only when I tried to install it on IOS Simulator (v.4.2). The orientation of the iOS device (v.4.1) also acted with Xcode 4.

It turned out (after frequent desperate attempts to interbreed) that the reason was almost a "hidden" setting in the .xib file:

Visit the .xib file properties in the file inspector: The Location property has been set to "Relative to group" for all .xib files. I changed it to “Regarding the project” and voila: all .xib files are now properly loaded in the iOS simulator!

I don't know what the reason for this is for this odd behavior of Xcode4, but maybe it's worth a try?

+15
Jun 17 2018-11-11T00:
source share

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

Returning to the main name of the main file of the main layout (UIMainStoryboardFile) solved the problem

+12
Feb 26 '14 at 2:44
source share

The error means that there is no .xib file named "JRProvidersController" . double-check if JRProvidersController.xib .

you download the .xib file with

 controller = [[JRProvidersController alloc] initWithNibName:@"JRProvidersController" bundle:nil]; 
+8
Mar 17 '11 at 10:51
source share

When the build target is one of my iOS devices, I right-click the Product file (xyzw.app) and select the Show in Finder pop-up menu. He opened a window with xyzw.app inside; I opened the package with Show Package Contents and saw all the files that I expected, except for the one file with which he complained, with the capital I am instead of the lowercase I in the name (zoomieVIew.nib instead of zoomieView.nib). I noticed a capital letter I in the xib file name and changed it and rebuilt; obviously, Xcode left the generated .nib name as it was. I uninstalled zoomieVIew.nib in the bundle, rebuilt, and Xcode properly recreated the file as zoomieView.nib. The application began to work on the device.

+6
Aug 06 '11 at 3:45
source share

Using the custom Swift view in the Objective-C view controller (yes, even after importing the <<PROJECT NAME>>-Swift.h ), I tried loading nib using:

 MyCustomView *customView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([MyCustomView class]) owner:self options:nil] objectAtIndex:0]; 

... but NSStringFromClass([MyCustomView class]) returns <<PROJECT NAME>>.MyCustomView and loading failed. TL; DR Everything worked fine, loading a thread using a string literal:

 MyCustomView *customView = [[[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil] objectAtIndex:0]; 
+6
May 18 '16 at 19:52
source share

I had this problem with the storyboard, and the nib was called something like "bKD-J3-fhr-view-ZSR-8m-2da".

This was because I was trying to add subview to self.view in the init view controller (withCoder). Self.view does not exist yet.

Moved it to viewDidLoad and all is better!

+5
Apr 04 '16 at 8:04 on
source share

Look at the project

Target -> Buid Phases -> Copy Bundle Resources

You will find your xib / storyborad with red.

Just delete it. Also remove all links of the missing file from the project.

Now drag this storyboard / xib file again to this Copy Bundle Resources . It will still show you a red file, but don’t worry about it.

Just clean and create a project.

Now you start your project again!

+4
Jun 19 '14 at 6:42
source share

I also found that it failed when I tried to load the XIB with a name like @ MyFile.xib. When I just used @MyFile, it worked - apparently, it always adds an extension. But the error message simply stated that he could not find MyFIle.xib in the package - if he said MyFile.xib.xib, that would be a big key.

+2
Jul 06 '13 at 16:26
source share

While working on Xcode 4.6.3 and localizing my NIB files, I also run into this problem.

Nothing else helped me except changing the "Document Version" in File Inspector to deploy 5.0 instead of 6.1.

+2
Aug 26 '13 at 21:20
source share

This happens when you rename the nib file. If you already have one, create a new nib (i.e. copy the current contents of the nib file to the new nib), delete the old nib file and it will solve your problem.

Edit: with the new start-up version of Xcode 4.6.3, if you rename (with the refactoring function) the controller class, it will also rename the nib file, and you do not need to worry about the problem of loading nib.

+2
Sep 05 '13 at 13:49 on
source share

I had an interesting experience using Xcode 6.3.

I, too, continued this mistake, despite the fact that you usually thought of spelling, targeted membership, etc., as suggested above. I also tried to clear, delete the derived data, and also remove the application from the simulator several times to ensure that the package was built correctly, but to no avail.

Finally, after Brian Michael Bentley's answer, I finally decided to check my .app file in my simulator folder on my HD. I found that all my feathers were there, but with abc ~ ipad.nib instead of the expected abc.nib. I manually renamed all these files to delete the ipad part that was created and worked!

Trying to understand why they were added with the ~ ipad keyword, I looked at the options for my project, and in fact, on my General> Deployment tab, I selected only the iPad. I tried to run the iPhone simulator. I believe that in the past Xcode threw an error indicating that the binary does not support the iPhone and you will not be able to launch the application.

I removed the application from the simulator and did the same thing again - again with only iPad support. This time .app contained abc ~ iphone.nib AND abc ~ ipad.nib for each expected storyboard, and it worked perfectly on the iPhone simulator. Yet again. If we select the iPad only in our Info Info settings, it should not run on iPhone Simulator. This is an Xcode error.

So, there is some inconsistency of behavior on the part of Xcode and, unfortunately, this is an intermittent error, and it can be difficult to reproduce, but I put it here so that it can help others in the future.

+2
May 15 '15 at 4:03
source share

If this same problem didn’t work, I realized something strange with derived data.

In xcode 6.3.2, I had to:

In the Xcode menu → Settings → Locations tab → Locations. Change the derived data to Relative and then switch to Default

Then the tweezers booted normally.

+2
Jul 02 '15 at 0:19
source share

Your XIB file is probably located outside your project folder. This causes the target inspector to not be displayed. However, moving the XIB file to the project folder should be fixed.

+2
Sep 22 '16 at
source share

DON'T WAY .xib WHEN YOU INSERT IN XIB NAME! THIS IS ALREADY IMPLIED!

Do not do this:

  UIView *viewFromNib = [[NSBundle mainBundle] loadNibNamed:@"ResultsAssessmentView.xib" owner:self options:nil][0]; 

Do it:

  UIView *viewFromNib = [[NSBundle mainBundle] loadNibNamed:@"ResultsAssessmentView" owner:self options:nil][0]; 
+2
Jul 10 '17 at 7:15
source share

Swift4 example if your MyCustomView.swift and MyCustomView.xib are within. Put this in the initialization of MyCustomView:

 let bundle = Bundle(for: type(of: self)) let nib = UINib(nibName: "MyCustomView", bundle: bundle) if let nibView = nib.instantiate(withOwner: self, options: nil).first as? UIView { self.aViewInMyCustomView = nibView self.aViewInMyCustomView.frame = self.frame self.addSubview(self.aViewInMyCustomView) // set constraints self.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0).isActive = true NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0).isActive = true NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0).isActive = true NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true } 
+2
Mar 15 '19 at 10:02
source share

If you use frameworks in your project, you need to make sure that you are loading from the correct package:

 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"<your bundle id here>"]; ABCViewController *vc = [[ABCViewController alloc] initWithNibName:@"<your nib name>" bundle:bundle]; 
+1
Jun 12 '15 at 2:07
source share

For storyboard

I tried every solution posted here, but it didn’t work, since I am using a storyboard with Swift 5.

I just started creating new controllers and views in a test storyboard application, but I found that I was missing My View Controller Storyboard ID.

So here is my solution if you want to go from ViewController A -> View Controller B

Step 1. In the storyboard: just make sure your ViewControllerA is built into the Navigation Controller

Step 2. In the storyboard: Now check to see if you have mentioned the Storyboard ID for your ViewControllerB, which you will use in your code as an identifier.

enter image description here

Step 3. And finally, make sure that you click the controller in this way in your ViewControllerA with the click of a button.

 if let viewControllerB = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewControllerB") as? ViewControllerB { if let navigator = navigationController { navigator.pushViewController(viewControllerB, animated: true) } } 
+1
May 18 '19 at 13:23
source share

Got this problem when converting my old code from Xcode 3x to Xcode 4 and Decided to just rename wwwwwwww.xib to RootViewController.xib

0
Jun 26 '11 at 17:17
source share

I ran into the same problem. In my case, the nib name was "MyViewController.xib" and I renamed it to "MyView.xib". This eliminated the error.

I also moved the project from Xcode 3 to 4.2. Changing the type of Path didn't matter.

0
Jun 30 '11 at 3:50
source share

Also, the reason may be a file search in the wrong language folder when you mixed up the localization.

0
Jan 25 2018-12-12T00:
source share

Every time I reorganize the name of the view controller, which in my appDelegate application is wasting time on this. Refactoring does not change the nib name in initWithNibName: @ "MYOldViewControllerName".

0
Jul 31 '13 at 10:15
source share

I had the same problem, renaming the view controller identifier in the storyboard worked for me.

0
Jan 22 '15 at 10:55
source share

I noticed that this can happen if you switch between branches in git and forget to make it clean. So, xib is there and it finds everything, but the exact build may have problems. So just in case, don't forget to clean

0
Mar 04
source share
 SecondViewController *secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondView.xib" bundle:nil]; [self.navigationController pushViewController:secondViewController animated:YES]; 

In the above code, if you also give the file extension, for example "SecondView.xib", then it is erroneous and will give you the error above. Use "SecondView" instead. I made this mistake.

0
Apr 27 '15 at 6:06
source share

This worked for me .. Make sure you type nib correctly.

[[NSBundle mainBundle] loadNibNamed: @ Owner of "Graphview": own parameters: nil];

Graphview (nib name)

0
Jun 02 '15 at 9:25
source share

I have the same problem and my .xib file .xib already linked to the Target Membership in the project. Then I unchecked the target file and checked again, then the Clean and Build project. Interestingly, it worked for me.

0
Feb 21 '18 at 8:07
source share

Be careful: Xcode is case sensitive with file names. This is not the same Fun as Fun.

0
Oct 18 '18 at 13:48
source share
  • one
  • 2



All Articles