In my project I've created an own Settings Bundle (called UIBundle), and dragged to it some of xib files. Then I'm trying to load them from bundle, for example this table view cell xib:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[self xibsBundle] loadNibNamed:@"MyCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
return cell;
}
- (NSBundle *) xibsBundle
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"UIBundle" ofType:@"bundle"];
return [NSBundle bundleWithPath:path];
}
But every time I run my app, it crashes when trying to load a cell with the following message:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/.../App.app/UIBundle.bundle> (not yet loaded)' with name 'MyCell''
Spent one day finding a solution without success. Any help would be appreciated.
P.S. Bundle is loaded successfully and any other resource besides xib files is accessible.
The only way to fix my issue was to follow the following steps:
Latest iOS
. I copied them to my own bundle and everything worked.