有没有办法在 Xcode 5 中编译单个文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20413747/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:23:38  来源:igfitidea点击:

Is there any way to compile a single file in Xcode 5?

xcodexcode5

提问by Straightfw

I'm talking about a functionality such that you can just quickly open a .cpp file (C++ console application, nothing regarding Apple ecosystem), work on it, compile and run, without all the project creating mumbo-jumbo. When I open a file with code, all the "Product" options are greyed out for me but after some googling, I found posts claiming that Xcode 5 was to be the first one offering such functionality. Has it been implemented and it's just available elsewhere or were they false rumors and you still have to create a project and import a file there?

我说的是一个功能,这样你就可以快速打开一个 .cpp 文件(C++ 控制台应用程序,与 Apple 生态系统无关),处理它,编译和运行,而无需创建 mumbo-jumbo 的所有项目。当我打开一个包含代码的文件时,所有“产品”选项对我来说都是灰色的,但经过一些谷歌搜索后,我发现有帖子声称 Xcode 5 是第一个提供此类功能的。它是否已实施并且仅在其他地方可用,或者它们是虚假的谣言,您仍然必须在那里创建一个项目并导入一个文件?

回答by Ajmal Kunnummal

Or if want a shortcut: CTRL + COMMAND + B.

或者如果想要快捷方式:CTRL + COMMAND + B。

回答by B. Nadolson

In the top menu of XCode "File - Edit - View" you will see Product.

在 XCode 的顶部菜单“文件 - 编辑 - 查看”中,您将看到产品。

Click Product->Perform Action->Compile "myfile.xxx"

点击产品->执行操作->编译“myfile.xxx”

If you want a shortcut for that command, click XCode -> Preferences-> Key Bindings and set one up.

如果您想要该命令的快捷方式,请单击 XCode -> Preferences-> Key Bindings 并设置一个。