xcode 如何修复 iPhone 模拟器尝试启动不存在的 Nib?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1148074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix iPhone Simulator trying to launch a Nib that isn't there?
提问by Thanks
I'm getting this error message when I Build&Go:
我在 Build&Go 时收到此错误消息:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] was unable to load a nib named "TestappViewController"'
*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIViewController _loadViewFromNibNamed:bundle:] 无法加载名为“TestappViewController”的笔尖”
I created a blank new project and then started to create a RootViewController which holds two other UIViewController's. XCode automatically created the TestappViewController, and I deleted it to start totally from scratch. MainWindow.xib shows me no TestappViewController in IB, but inside the XML structure of MainWindow.xib I find this:
我创建了一个空白的新项目,然后开始创建一个包含另外两个 UIViewController 的 RootViewController。XCode 自动创建了 TestappViewController,我将其删除以完全从头开始。MainWindow.xib 在 IB 中没有显示 TestappViewController,但在 MainWindow.xib 的 XML 结构中我发现了这个:
<object class="IBUIViewController" id="943309135">
<string key="IBUINibName">TestappViewController</string>
<object class="IBUISimulatedStatusBarMetrics"
key="IBUISimulatedStatusBarMetrics"/> </object>
I checked all my XIB's for a reference to an TestappViewController, but there's nothing. Testapp-Info.plist points to MainWindow.xib only.
我检查了我所有的 XIB 以获取对 TestappViewController 的引用,但什么也没有。Testapp-Info.plist 仅指向 MainWindow.xib。
Tried to delete this part out of the XML from MainWindow.xib, but this gives some weird Xcode errors, so I re-inserted it. I assume the bug in the XIB files, but don't find anything.
试图从 MainWindow.xib 的 XML 中删除这部分,但这会产生一些奇怪的 Xcode 错误,所以我重新插入了它。我假设 XIB 文件中的错误,但没有找到任何东西。
Any idea at which point I could fix that?
知道在哪一点我可以解决这个问题吗?
回答by Thanks
Finally I figured out that I had to delete and recreate the View Controller object in the MainWindow.xib. Previously I just edited the existing View Controller object and directed it to another class, which doesn't seem to work properly. Now all is fine :)
最后我发现我必须删除并重新创建 MainWindow.xib 中的 View Controller 对象。以前我只是编辑了现有的 View Controller 对象并将其定向到另一个类,这似乎无法正常工作。现在一切都很好:)
回答by Armin
Go to iPhone Simulator, then click on "Reset content and settings". That did the job for me.
转到 iPhone 模拟器,然后单击“重置内容和设置”。那为我完成了工作。
回答by Hagan
I had this problem, none of the above solutions worked. For me, I had to right click the xib file in the Resources folder > get info and in the Targets tab make sure the target box for my app was checked.
我遇到了这个问题,上述解决方案均无效。对我来说,我必须右键单击资源文件夹中的 xib 文件 > 获取信息,然后在目标选项卡中确保选中我的应用程序的目标框。
回答by ennuikiller
In iB in the connections inspector for the mainwindow make sure the connection to the TestappviewViewController is deleted
在主窗口的连接检查器中的 iB 中,确保删除与 TestappviewViewController 的连接
回答by Brad The App Guy
Most likely, the file's owner of the View Controller object in the MainWindow.xib was set to TestappViewController, instead of UIView controller. What you could have done is change it back to UIViewController in the Identity Inspector (4th TAb)
最有可能的是,MainWindow.xib 中视图控制器对象的文件所有者设置为 TestappViewController,而不是 UIView 控制器。您可以做的是在身份检查器(第 4 个选项卡)中将其改回 UIViewController
回答by flagg19
Go to: Application Support -> iPhone Simulator -> *your_simulator_version* Delete the folder related to your app, clean solution, run the app.
转到:应用程序支持 -> iPhone 模拟器 -> *your_simulator_version* 删除与您的应用程序相关的文件夹,清理解决方案,运行应用程序。
It worked for me... the problematic xib was still in that folder after i removed it from the project and for some reason, the app tried to load it even if there was absolutely no ref in xcode.
它对我有用......在我将其从项目中删除后,有问题的 xib 仍在该文件夹中,并且出于某种原因,即使 xcode 中绝对没有引用,该应用程序也会尝试加载它。