简体   繁体   English

Xcode:Interface Builder XIB编译器错误

[英]Xcode: Interface Builder XIB Compiler Error

Xcode 5.1.1 and OS X 10.9.3 Xcode 5.1.1和OS X 10.9.3

I open Xcode and start a new Cocoa project. 我打开Xcode并启动一个新的Cocoa项目。 I then click run. 然后我点击运行。 The build fails, and I get the following error message: 构建失败,我收到以下错误消息:

Interface Builder XIB Compiler Error
Interface Builder was unable to determine the type of "MainMenu.xib".

I also don't see the usual WYSIWYG editor when I select MainMenu.xib just a black screen. 当我选择MainMenu.xib只是一个黑屏时,我也没有看到通常的WYSIWYG编辑器。 I notice the "type" of file is "Default - Abstract Interface Builder File", whereas on other working projects I have built in the past, the "type" is "Default - Interface Builder File". 我注意到文件的“类型”是“默认 - 抽象接口构建器文件”,而在我过去构建的其他工作项目中,“类型”是“默认 - 接口构建器文件”。 Seems there's something about it being an "abstract" file that's causing Xcode to not display the interface builder. 似乎有一些关于它是一个“抽象”文件,导致Xcode不显示界面构建器。

I tried fully uninstalling Xcode and re-downloading it from the App Store. 我尝试完全卸载Xcode并从App Store重新下载。 Didn't help. 没有帮助。 Multiple google searches have turned up nothing helpful, and the other Stack Overflow questions with a similar title to mine aren't illuminating. 多个谷歌搜索没有任何帮助,其他Stack Overflow问题与我的类似标题并不是很有启发性。 I can't imagine everyone else with Xcode 5.1 has this issue. 我无法想象Xcode 5.1的其他人都有这个问题。 Any experts out there that could suggest a quick fix? 那里的任何专家都可以建议快速修复?

在此输入图像描述在此输入图像描述在此输入图像描述在此输入图像描述

Aha! 啊哈! What a ridiculous solution! 多么荒谬的解决方案! Hope this helps somebody. 希望这有助于某人。

Add a new xib file! 添加一个新的xib文件!

And delete the old MainMenu.xib for good measure. 并删除旧的MainMenu.xib以获得良好的衡量标准。 The new xib will show up as expected. 新的xib将按预期显示。

在此输入图像描述

But wait - there's more! 但是等等 - 还有更多!

I'm not sure if it's just that my Xcode is horribly corrupted, but here's what else I had to do to get my application to run successfully: 我不确定是不是只是因为我的Xcode被严重破坏了,但是我还需要做些什么来让我的应用程序成功运行:

1 - Go to your general project settings and set the Main Interface to your new xib file's name without the .xib extension! 1 -转到您的一般项目设置和主界面设置为您的新厦门国际银行文件的名称不带.xib扩展! Otherwise, you'll get output in your console that says Unable to load nib file . 否则,您将在控制台中输出Unable to load nib file See pics to compare. 请参阅图片进行比较。 This will get your blank app window to pop up when you run the program. 这将使您在运行程序时弹出空白应用程序窗口。

在此输入图像描述在此输入图像描述

2 - Now you need your app delegate to do stuff. 2 - 现在你需要你的app委托来做事。 Drag an Object from the object library to the list of objects in the interface builder. Object从对象库拖到界面构建器中的对象列表中。 Define its class as your app delegate class name and the object should rename itself to 'App Delegate'. 将其类定义为您的app委托类名,该对象应将自身重命名为“App Delegate”。

在此输入图像描述

3 - control drag from Application to App Delegate and select 'delegate'. 3 - 控制从ApplicationApp Delegate拖动并选择'delegate'。 Now your app delegate code will work. 现在您的应用委托代码将起作用。

4 - Add a NSLog(@"app success!"); 4 - 添加NSLog(@"app success!"); statement in the applicationDidFinishLaunching method to confirm you did everything correctly, hit run, watch the window pop up and the NSLog output into the console, and congratulate yourself for making an Apple product work the way it should have been designed to work. applicationDidFinishLaunching方法中的语句,用于确认您已正确执行所有操作,点击运行,查看窗口弹出窗口以及NSLog输出到控制台中,并祝贺您自己使Apple产品以其应该设计的方式工作。

我通过从项目设置 - >构建阶段 - >复制捆绑引用中删除重复引用来解决此问题

I fixed the problem by opening "Xcode-Macintosh HD" instead of "Xcode- Developer" after searching it from spotlight. 我从聚光灯下搜索后打开“Xcode-Macintosh HD”而不是“Xcode- Developer”来解决问题。 (Spotlight is the magnifying glass in the top right) (聚光灯是右上角的放大镜)

I got a similar error with a brand new project when I had a special character (&) in the Organization Name. 当我在组织名称中有一个特殊字符(&)时,我在一个全新的项目中遇到了类似的错误。 The OP doesn't seem to have this situation, but maybe this will help others who find their way here. OP似乎没有这种情况,但也许这将有助于其他人在这里找到他们的方式。 This seems to be a new bug with Xcode 6. 这似乎是Xcode 6的一个新bug。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM