[ios] Could not load NIB in bundle

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?

This question is related to ios iphone xcode titanium appcelerator

The answer is


For me, the case was that I was searching the main bundle for a nib which wasn't in the main bundle. My nib was in an imported module so I needed to retrieve the bundle for that module and use it to init the UINib, rather than using Bundle.main.


For Storyboard

I tried every single solution posted here but nothing worked for me as I am using Storyboard with Swift 5.

Just started to build fresh controllers and Views in storyboard test app, what I found is I was missing My View Controller's Storyboard ID.

So here is my solution, If you want to Go from ViewController A --> View Controller B

Step 1. In storyboard : Just make sure your ViewControllerA is embedded in Navigation Controller

Step 2. In storyboard : Now check have you mentioned Storyboard ID for your ViewControllerB which you will use in code as Identifier.

enter image description here

Step 3. and finally make sure you are pushing controller this way in your ViewControllerA with Button click.

if let viewControllerB = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewControllerB") as? ViewControllerB {

            if let navigator = navigationController {
                navigator.pushViewController(viewControllerB, animated: true)
            }
        }

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

In the above code, if you also give a file extension like "SecondView.xib", then it's wrong and will give you above error. Use "SecondView" instead. I have made that mistake.


Your XIB file is probably outside your project folder. This leads to not showing up the Target Inspector. However, moving the XIB file into your project folder should fix it.


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

It was because I was trying to add a subview to self.view in a view controller's init (withCoder). Self.view doesn't exist yet.

Moved it to viewDidLoad and all better!


I've got same issue and my .xib file has already linked in Target Membership with the Project. Then I unchecked the file's target checkbox and checked again, then Clean and Build the project. Interestingly it has worked for me.


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


Every time I refactor a view controller's name that's in my appDelegate I waste time on this. Refactoring doesn't change the nib name in initWithNibName:@"MYOldViewControllerName".


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


Working on Xcode 4.6.3 and localizing my NIB files I also run into this issue.

For me nothing else helped besides changing "Document Versioning" in File Inspector to Deployment 5.0 instead of 6.1.


the error means that there is no .xib file with "JRProvidersController" name. recheck whether JRProvidersController.xib exists.

you will load .xib file with

controller = [[JRProvidersController alloc] initWithNibName:@"JRProvidersController" bundle:nil];

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

I was also moving a project from XCode 3 to 4.2. Changing the Path type did not matter.


Using a custom Swift view in an Objective-C view controller (yes, even after importing the <<PROJECT NAME>>-Swift.h file), I'd tried to load the nib using:

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

...but NSStringFromClass([MyCustomView class]) returns <<PROJECT NAME>>.MyCustomViewand the load fails. TL;DR All worked well loading the nib using a string literal:

MyCustomView *customView = [[[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil] objectAtIndex:0];

Have look on project

Target -> Buid Phases -> Copy Bundle Resources

You will find your xib/storyborad with red color.

Just remove it.Also remove all references of missing file from project.

Now drag this storyboard/xib file again to this Copy Bundle Resources.It will still show you file with red color but dont worry about it.

Just clean and build project.

Now you will get your project running again successfully!!


In case you are using frameworks in your project, you need to make sure you are loading from the correct bundle:

NSBundle *bundle = [NSBundle bundleWithIdentifier:@"<your bundle id here>"];
ABCViewController *vc = [[ABCViewController alloc] initWithNibName:@"<your nib name>" bundle:bundle];

try to find out all

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

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


Had this same issue nothing worked, so I figured something weird with derived data.

In xcode 6.3.2 I had to:

In XCode Menu --> Preferences --> Locations Tab --> In Locations Change Derived Data to Relative and then toggle back to Default

Then the nib loaded fine.


DO NOT PUT .xib WHEN YOU INSERT IN THE XIB NAME! IT IS ALREADY IMPLIED!

Dont do this:

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

Do this:

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

With the build target being one of my iOS devices, I right-clicked the Product file (xyzw.app) and selected the Show in Finder popup item. It opened a window with the xyzw.app inside; I opened the bundle using Show Package Contents and saw all the files I expected, except one file, the one it was complaining about, with a capital I instead of a lower-case i in the name (zoomieVIew.nib instead of zoomieView.nib). I had noticed the uppercase I in the file name of the xib, and changed it and rebuilt; apparently Xcode left the generated .nib name the way it was. I deleted zoomieVIew.nib in the bundle, rebuilt, and Xcode duly recreated the file as zoomieView.nib. The app started to work on the device.


It happens when you rename the nib file. If you have already, create new nib(meaning copy current nib file contents to new nib), delete old nib file and it will solve your problem.

Edit: With new Xcode starting version 4.6.3, If you rename(with refactor feature) Controller class, it will rename nib file too and you need not worry about nib loading problem.


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


Be careful: Xcode is caseSensitive with file names. It's not the same "Fun" than "fun".


I just had an interesting experience using Xcode 6.3.

I kept getting this error also, despite trying everything you would normally think of with spelling, target membership, etc. as suggested above. I also tried cleaning, deleting derived data, and also deleting the app from the simulator several times to ensure the bundle was being built correctly but to no avail.

Finally, following Brian Michael Bentley's answer, I finally decided to inspect my .app file in my simulator's folder on my HD. I found that all of my nibs were there but with a abc~ipad.nib instead of the expected abc.nib. I manually renamed all of these files to remove the ~ipad part, built and it worked!

Trying to see why these have been appended with the ~ipad keyword, I looked at my project settings and in fact, in my General>Deployment Info tab, I had only iPad selected. I was trying to run on an iPhone simulator. I believe that in the past, Xcode would give an error indicating that the binary did not support iPhone and you would not succeed in running the app.

I deleted the app from the simulator and did the same thing again - again with only iPad supported. This time, the .app contained abc~iphone.nib AND abc~ipad.nib for each expected storyboard and it ran on the iPhone simulator just fine. Again - If we choose iPad only in our Deployment Info settings, it shouldn't run on iPhone Simulator. This is an Xcode bug.

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


This is worked for me.. Make sure you typed nib name correctly.

[[NSBundle mainBundle]loadNibNamed:@"Graphview" owner:self options:nil];

Graphview(nib name)


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


In Targets -> Build Phases

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


In my case, I was creating a framework with Cocoapods. The problems was this line:

s.static_framework = true

in my framework.podspec file

After commented this line above all problems to access storyboards or XIBs went out.


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 ?


Also the reason can be the file is looked up in the wrong language specific folder when you messed with localizations.


Got this problem while transforming my old code from XCode 3x to XCode 4 and Solved it by just renaming wwwwwwww.xib into RootViewController.xib


Swift4 example if your MyCustomView.swift and MyCustomView.xib in a framework. Place this in the MyCustomView's init:

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
} 

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 the extension. But the error message just said it couldn't find MyFIle.xib in the bundle - if it had said MyFile.xib.xib, that would have been a big clue.


for me, it solved just by changing the name of my cell's file into the same as its class.

In Attributes Inspector(Third tab on the right side bar in story board):

  1. Set the cell's Identifier( for example: "MyCellId"),
  2. Set the cell's Class (for example: "MyCellClass" when the file is "MyCellClass") ,
  3. Register the cell in your view controller as follow:

    tableView.register(UINib(nibName: "MyCellClass", bundle: nil), forCellReuseIdentifier: "MyCellId")


In my case the spellings of XIB was incorrect. Please make sure the spellings are correct. Bundle.main.loadNibName("XIB_Name" , owner : self , options :nil)


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to iphone

Detect if the device is iPhone X Xcode 8 shows error that provisioning profile doesn't include signing certificate Access files in /var/mobile/Containers/Data/Application without jailbreaking iPhone Certificate has either expired or has been revoked Missing Compliance in Status when I add built for internal testing in Test Flight.How to solve? cordova run with ios error .. Error code 65 for command: xcodebuild with args: "Could not find Developer Disk Image" Reason: no suitable image found iPad Multitasking support requires these orientations How to insert new cell into UITableView in Swift

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to titanium

Xamarin 2.0 vs Appcelerator Titanium vs PhoneGap How to check if array element exists or not in javascript? Where does application data file actually stored on android device? Could not load NIB in bundle Check if a file exists locally using JavaScript only

Examples related to appcelerator

Where does application data file actually stored on android device? Could not load NIB in bundle