创建没有 NIB 文件的 Cocoa 应用程序 [英] Creating a Cocoa application without NIB files

查看:25
本文介绍了创建没有 NIB 文件的 Cocoa 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道这违背了整个 MVC 原则!

Yes, I know this goes against the whole MVC principle!

然而,我只是想创建一个非常简单的应用程序 - 我已经实现了它.但是,我有一个问题...

However, I'm just trying to whip up a pretty trivial application - and I've pretty much implemented it. However, I have a problem...

我创建了一个空项目,复制了所有框架并设置了构建设置 - 我收到有关可执行文件或缺少可执行文件的错误.构建设置看起来都很好,但它告诉我没有可执行文件 - 它将构建 + 运行良好.但是它不运行.也没有错误 - 它似乎运行得非常快速和干净!除非我尝试运行 GDB,它礼貌地告诉我我需要先给它一个文件..

I create an empty project, copy all the frameworks over and set the build settings - and I get errors about the executable, or lack of executable. The build settings all appear fine, but it tells me there is no executable - it will build + run fine. However it doesn't run. There is no error either - it just appears to run very fast and cleanly! Unless I try and run GDB which politely tells me I need to give it a file first..

Running…  
No executable file specified.  
Use the "file" or "exec-file" command.

所以我创建了一个 Cocoa 应用程序,删除了所有我不需要的东西(即 MainMenu.xib 文件..),现在我可以完美地编译我的代码.然而它死了抱怨它是

So I created a Cocoa application, removed all the stuff I didn't need (that is, the MainMenu.xib file..), and now I can compile my code perfectly. However it dies complaining that it's

无法加载 nib 文件:MainMenu,正在退出"

"Unable to load nib file: MainMenu, exiting"

我已经浏览了项目符号并看到代码实际上严重依赖于 NIB 文件,即使您没有在代码方面接触它.(我猜又是MVC..)

I have gone through the Project Symbols and see that the code actually relies upon the NIB file heavily, even if you don't touch it code-wise. (MVC again I guess..)

有没有一种简单的方法来编译你编写的代码,不添加 NIB 文件,只编译你编写的代码和添加的框架?我认为这将是一个空白项目,但我的经验告诉我不然?!

Is there a simple way to compile just what you code, no added NIB files, just the code you write and the frameworks you add? I assume it would be a blank project, but my experience tells me otherwise?!

推荐答案

当然,您可以只编写代码而不使用 Interface Builder.

Of course you can write just code and not use Interface Builder.

你检查过你的 Info.plist 了吗?默认情况下,MainMenu.xib 有一个条目,它可能是它抱怨的引用.

Have you checked your Info.plist? By default there is an entry there for MainMenu.xib and it may be that reference it's complaining about.

这篇关于创建没有 NIB 文件的 Cocoa 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆