Xcode:Interface Builder XIB 编译器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23924536/
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
Xcode: Interface Builder XIB Compiler Error
提问by Ryan Tuck
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. I then click run. The build fails, and I get the following error message:
我打开 Xcode 并开始一个新的 Cocoa 项目。然后我点击运行。构建失败,我收到以下错误消息:
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. 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.
当我MainMenu.xib
只选择一个黑屏时,我也看不到通常的 WYSIWYG 编辑器。我注意到文件的“类型”是“默认 - 抽象界面生成器文件”,而在我过去构建的其他工作项目中,“类型”是“默认 - 界面生成器文件”。似乎它是一个“抽象”文件,导致 Xcode 不显示界面构建器。
I tried fully uninstalling Xcode and re-downloading it from the 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. I can't imagine everyone else with Xcode 5.1 has this issue. Any experts out there that could suggest a quick fix?
我尝试完全卸载 Xcode 并从 App Store 重新下载它。没有帮助。多次谷歌搜索没有发现任何帮助,与我的标题相似的其他 Stack Overflow 问题也没有启发性。我无法想象使用 Xcode 5.1 的其他人都有这个问题。有没有专家可以建议快速修复?
采纳答案by Ryan Tuck
Aha! What a ridiculous solution! Hope this helps somebody.
啊哈!多么荒谬的解决方案!希望这可以帮助某人。
Add a new xib file!
添加一个新的 xib 文件!
And delete the old MainMenu.xib
for good measure. The new xib will show up as expected.
并删除旧的MainMenu.xib
以更好地衡量。新的 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!Otherwise, you'll get output in your console that says Unable to load nib file
. See pics to compare. This will get your blank app window to pop up when you run the program.
1 - 转到您的常规项目设置并将主界面设置为您的新 xib 文件的名称,不带.xib
扩展名!否则,您将在控制台中看到显示Unable to load nib file
. 查看图片进行比较。这将使您在运行程序时弹出空白的应用程序窗口。
2 - Now you need your app delegate to do stuff. Drag an Object
from the object library to the list of objects in the interface builder. Define its class as your app delegate class name and the object should rename itself to 'App Delegate'.
2 - 现在你需要你的应用委托来做事。将Object
对象库中的 拖到界面构建器中的对象列表中。将其类定义为您的应用程序委托类名称,并且该对象应将自身重命名为“应用程序委托”。
3 - control drag from Application
to App Delegate
and select 'delegate'. Now your app delegate code will work.
3 - 控制从Application
到拖动App Delegate
并选择“委托”。现在您的应用程序委托代码将起作用。
4 - Add a 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.
4 -NSLog(@"app success!");
在applicationDidFinishLaunching
方法中添加一条语句来确认你做的一切都是正确的,点击运行,观察弹出的窗口和 NSLog 输出到控制台,并祝贺你自己让 Apple 产品按照它应该设计的方式工作。
回答by Thippi
I have solved this problem by removing duplicate reference from project settings -> build phases -> copy bundle references
我通过从项目设置中删除重复引用解决了这个问题 -> 构建阶段 -> 复制包引用
回答by firescar96
I fixed the problem by opening "Xcode-Macintosh HD" instead of "Xcode- Developer" after searching it from spotlight. (Spotlight is the magnifying glass in the top right)
我通过在聚光灯下搜索后打开“Xcode-Macintosh HD”而不是“Xcode-Developer”来解决这个问题。(聚光灯是右上角的放大镜)
回答by James Nick Sears
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. This seems to be a new bug with Xcode 6.
当我在组织名称中有一个特殊字符 (&) 时,我在一个全新的项目中遇到了类似的错误。OP 似乎没有这种情况,但也许这会帮助其他在这里找到方法的人。这似乎是 Xcode 6 的一个新错误。