Iphone NSInternalInconsistencyException-无法加载捆绑包中的NIB:

Iphone NSInternalInconsistencyException-无法加载捆绑包中的NIB:,iphone,ios,uiviewcontroller,bundle,resourcebundle,Iphone,Ios,Uiviewcontroller,Bundle,Resourcebundle,我正试图将我所有的.xib资源捆绑到一个“ViewController.bundle”中,与“MyLibrary.framework”一起发布。如果我把所有的.xib文件都放在框架项目中,一切正常,但是如果我把它们放在“ViewController.bundle”中,一切都会崩溃 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NI

我正试图将我所有的.xib资源捆绑到一个“ViewController.bundle”中,与“MyLibrary.framework”一起发布。如果我把所有的.xib文件都放在框架项目中,一切正常,但是如果我把它们放在“ViewController.bundle”中,一切都会崩溃

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'Could not load NIB in bundle: 
'NSBundle </Users/administrator/Library/Application Support/iPhone Simulator/5.0/
Applications/8AD68FD1-158E-4926-AE03-8FEF870E7012/ios.app/ViewController.bundle> 
(not yet loaded)' with name 'FirstViewController_iPhone''
*** First throw call stack:
(0x160e052 0x1071d0a 0x15b6a78 0x15b69e9 0x3ff838 0x2a6e2c 0x2a73a9 0x2a75cb 0x2c2b89 0x2c29bd  
0x2c0f8a 0x2c0d7e 0x2c0a22 0x2bfd88 0x5e3ac 0x2df8 0x2e34 0x160fec9 0x1e45c2 0x1e455a 0x289b76 
0x28a03f 0x2892fe 0x209a30 0x209c56 0x1f0384 0x1e3aa9 0x1eedfa9 0x15e21c5 0x1547022 0x154590a    
0x1544db4 0x1544ccb 0x1eec879 0x1eec93e 0x1e1a9b 0x2452 0x2385)
使用相同的代码加载xib失败:

NSBundle *bViewController = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"ViewController" withExtension:@"bundle"]];
if ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) {
    self.m_pFirstViewController = [[[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:bViewController] autorelease];
    self.m_pSecondViewController = [[[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:bViewController] autorelease];
} else {
    self.m_pFirstViewController = [[[FirstViewController alloc] initWithNibName:@"ViewController.bundle/FirstViewController_iPad" bundle:nil] autorelease];
    self.m_pSecondViewController = [[[SecondViewController alloc] initWithNibName:@"ViewController.bundle/SecondViewController_iPad" bundle:nil] autorelease];
}

    /** It crash in this line!! Note however, both m_pFirstViewController and m_pSecondViewController is allocated and not nil */
self.viewControllers = @[self.m_pFirstViewController, self.m_pSecondViewController];

    /** never reach here already crash */
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:self animated:YES completion:^{
    NSLog( @"presented!" );
}];

在过去的8个小时里,我一直在调试这个,在谷歌上搜索,并尝试了来自SO的各种建议,但都没有用。。。非常感谢您的帮助!谢谢

我尝试的第二种方法是最接近。。。然后在构建设置中将OSX捆绑包修改为iOS捆绑包。显然,我错过了几个步骤。我遵循Matt Galloway的教程和示例项目:

现在一切都按计划进行了


谢谢大家的帮助

我的某些控件可能从xib中删除,并映射为xib.no,所有的.xib都包括在内,但是,我检查了.app中的.bundle,它们都按原样包括在内。ie:.xib,但错误似乎是在等待编译版本(.nib)谢谢!添加说明:如果您的png文件正在转换为TIFF,请添加此“用户定义”生成设置:
COMBINE\u HIDPI\u IMAGES=NO
NSBundle *bViewController = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"ViewController" withExtension:@"bundle"]];
if ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) {
    self.m_pFirstViewController = [[[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:bViewController] autorelease];
    self.m_pSecondViewController = [[[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:bViewController] autorelease];
} else {
    self.m_pFirstViewController = [[[FirstViewController alloc] initWithNibName:@"ViewController.bundle/FirstViewController_iPad" bundle:nil] autorelease];
    self.m_pSecondViewController = [[[SecondViewController alloc] initWithNibName:@"ViewController.bundle/SecondViewController_iPad" bundle:nil] autorelease];
}

    /** It crash in this line!! Note however, both m_pFirstViewController and m_pSecondViewController is allocated and not nil */
self.viewControllers = @[self.m_pFirstViewController, self.m_pSecondViewController];

    /** never reach here already crash */
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:self animated:YES completion:^{
    NSLog( @"presented!" );
}];