I lost half a day figuring this and I can\'t see a straight forward solution online.
I created an iOS CocoaTouch Framework. I have some private and public classes in it
Background to my answer:
I was trying to export some UITableView
related implementation and it had UITableViewCell
.xib
files packed with it. And they turn into .nib
files at the end! ;-) And I was referring to those Nib files as follows:
[[NSBundle mainBundle] loadNibNamed:customCellID owner:nil options:nil];
Explanation:
But here the thing I have done wrong is, I build a static Cocoa Touch Framework and try to use it within another Application. So at the run time what would become the MainBundle
? Definitely my UITableView implementation trying to find out that Nib file for the customCellID in within the App's main bundle.
Answer:
So I altered my UITableView
implementation's above code snippet as follows:
NSString *frameworkBundleId = @"com.randika.MyFrameworkBundleIDHere";
NSBundle *resourcesBundle = [NSBundle bundleWithIdentifier:frameworkBundleId];
customCell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:customCellID];
if (customCell == nil) {
NSArray *nibs = [resourcesBundle loadNibNamed:emptyCellID owner:nil options:nil];
customCell = [nibs objectAtIndex:0];
}
And the framework I built out of my UITableView
implementation didn't give the above error ever again! :-)
Hope this answer might be helpful to somebody out there!
Cheers! :-)