I am trying to make a universal framework, for iOS by following steps specified in this URL: Universal-framework-iOS
I have a viewController class within, that framework which internally loads a .xib file.
Below is a part of code which shows, how I am initializing that viewController and showing related view:
/*** Part of implementation of SomeViewController class, which is outside the framework ***/
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.viewControllerWithinFramework = [[ViewControllerWithinFramework alloc] initWithTitle:@"My custom view"];
}
- (IBAction)showSomeView:(id)sender {
[self.viewControllerWithinFramework showRelatedView];
}
/*** Part of implementation of ViewControllerWithinFramework class, which is inside the framework ***/
- (id)initWithTitle:(NSString *)aTitle
{
self = [super initWithNibName:@"ViewControllerWithinFramework" bundle:nil]; // ViewControllerWithinFramework.xib is within the framework
if (self)
{
_viewControllerTitle = aTitle;
}
return self;
}
While creating the framework, I included all .xib files, including ViewControllerWithinFramework.xib within its Copy Bundle Resources
build phase.
Now my problem is when I try to integrate that framework within other project, it crashes with below stack trace:
Sample[3616:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/miraaj/Library/Application Support/iPhone Simulator/7.0/Applications/78CB9BC5-0FCE-40FC-8BCB-721EBA031296/Sample.app> (loaded)' with name 'ViewControllerWithinFramework''
*** First throw call stack:
(
0 CoreFoundation 0x017365e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b98b6 objc_exception_throw + 44
2 CoreFoundation 0x017363bb +[NSException raise:format:] + 139
3 UIKit 0x004cc65c -[UINib instantiateWithOwner:options:] + 951
4 UIKit 0x0033ec95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
5 UIKit 0x0033f43d -[UIViewController loadView] + 302
6 UIKit 0x0033f73e -[UIViewController loadViewIfRequired] + 78
7 UIKit 0x0033fc44 -[UIViewController view] + 35
Any ideas, how could I resolve this problem?
Note: It works fine if there is no any xib within the framework.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…