Could not load NIB in bundle: 'NSBundle'
What is the error listed below?
2011-02-23 21:24:12.218 Success[7238:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyExce开发者_StackOverflow中文版ption', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (loaded)' with name 'MainWindow-iPad''
One of your NIB file is missing from project, add the required NIB file:
In Build Phases
- expand Copy Bundle Resources
- click
+
at bottom - add the required NIB file.
Clean your build by Shift+Cmd+K
, then run.
P.S. Also make sure to use exact spelling of NIB file while calling initWithNibName:@"ViewNameController"
Probably, you have named your NIB in a call by lowercase letters or you may have also included extension .xib which is not required.
Probably, you have named your NIB in a call by lowercase letters. The simulator works fine in this case, but an iPhone device will return an error during runtime.
For example,
DetailViewController *detailViewController = [[DetailViewController alloc]
initWithNibName:@"detailViewController" bundle:nil];
will fail. You need to change to:
DetailViewController *detailViewController = [[DetailViewController alloc]
initWithNibName:@"DetailViewController" bundle:nil];
In your Build Settings, Add Architecture =>> armv6 and armv7
I just removed my error using this
I have got the same problem, but it was because i wrote the extension .xib and it is not neccessary
token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad.xib" bundle:nil];
instead of
token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad" bundle:nil];
In my case was next:
I loaded in code XIB with name "??????Ipad" but XIB filename was "??????IPad"
Are there any warnings related to the NIB? This is usually do to an error in the NIB file (such as incorrect type of NIB).
Right click on the file and click "Get Info" to verify that the type is what you would expect.
An other possible issue: you are using Base Localization on iOS 5 (caution, it kinda work on the iOS Simulator, but not on a device), but it is supported only starting from iOS 6.
For more info, see: Could not load nib in bundle base internationalization
Please make sure your nib/xib file is included in the corresponding Target Membership.
I Have Same Problem Just Follow Steps.
1.Copy your Project In Another Place.
2.Copy your NIB File Which Crash app.
3.Just Change Name
Ex. Old File Demo.xib Than Copy And Change Name DemoNew.xib
My Code is Below
Old Code
Demo *controller = [[Demo alloc]initWithNibName:@"Demo" bundle:nil];
I Just Change Name
Demo *controller = [[Demo alloc]initWithNibName:@"DemoNew" bundle:nil];
its working for me.
Just check that file MainWindow.xib
exist in your project. If not, just add the new interface file with name MainWindow.xib
.
If you are trying to load a collectionView cell in a collection view which is picked up from a nib then you might be seeing the error" 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle " When you are loading a collection view from a nib file, you do not have the option to declare a collection view cell on the nib unlike story board. The correct way is to create a new custom cell , with a new nib and then load it on to the collection view. Note : don't forget to register the nib of the new custom collection cell.
0
For example If your using a UIViewController class name as TextPicker Then u need to use like Bellow Code
let bundle = Bundle(for: TextPicker.self)
super.init(nibName: "TextPicker" , bundle: bundle)
If You are using TableView with Xib in other project as Framework
tableView.register(UINib.init(nibName: "TextPickerCell", bundle: bundle), forCellReuseIdentifier: "TextPickerCell")
let bundle = Bundle(for: TextPicker.self)
In my case, the error was "Incorrect name for nib file in:
collectionViewOutlet.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "Cell")
Recommend making all of them the same, the cell identifier and nibName
as well so make it:
collectionViewOutlet.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "CollectionViewCell")
If it doesn't work try this:
Target -> Build Phases -> Copy Bundle Resources
You will find your xib/storyborad
with red color.
Just remove it. Also, remove all references of the missing files from the project.
Now drag this storyboard/xib
file again to this Copy Bundle Resources. It will still show you a file with red color but don't worry about it.
Command + Shift + K to clean the project and it will work.
In my case (using XCode 12.5 and Swift 5) the problem was that I choosed the NIBName based on the name of my ViewController:
let nibName = String(describing: type(of: self))
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: nibName, bundle: bundle)
let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView
So I had "TestView.xib" and "TestViewController.swift". This mismatched and could only be resolved by renaming my ViewController to "TestView.swift".
精彩评论