如何编译单个文件 Xcode 4?

发布于 2024-10-12 08:24:16 字数 207 浏览 9 评论 0原文

虽然我曾经在 Xcode 的早期版本中使用 Cmd+K 编译单个源文件,但在 Xcode 4 中如何执行相同操作? (请注意,这与预处理或显示文件的反汇编不同。)如果建议从命令行进行编译,则必须包含项目的设置、包含路径、预处理器定义等。

一个示例用例是,我更改了头文件,但只想测试更改对单个源文件的影响,而不是测试依赖于该头文件的所有文件。

While I used to compile a single source file with Cmd+K in prior versions of Xcode, how does one do the same in Xcode 4? (Note that this is different than preprocessing or showing the disassembly of the file.) If compiling from a command line is proposed then it must be such that the project's settings, include paths, preprocessor definitions, etc., are all included.

An example use case is where I make a header file change but only want to test the change's effect with respect to a single source file, not all of the files that depend upon that header.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

独留℉清风醉 2024-10-19 08:24:17

单文件编译的常见要求是检查语法错误。 (至少对我来说)。由于 xcode4 在您键入时会突出显示语法错误。苹果似乎删除了该功能。

The common requirement for single file compilation is checking it for syntax errors. (atleast for me). Since xcode4 highlights syntax errors as you type. It seems apple removed that feature.

十级心震 2024-10-19 08:24:16

该命令已移至“执行操作”子菜单。查看

Product > Perform Action > Compile filename.cpp

“要将 Cmd+K 分配给它”下,转到

File > Preferences > Key Bindings > Product Menu group

“编译文件”,您可以在其中分配密钥。 Cmd+K 现在默认分配给 Clear Console,因此请务必删除该绑定以避免冲突。

The command has been moved to the Perform Action submenu. Look under

Product > Perform Action > Compile filename.cpp

To assign Cmd+K to it, go to

File > Preferences > Key Bindings > Product Menu group

and you'll find Compile File where you can assign a key. Cmd+K is assigned to Clear Console now by default, so be sure to remove that binding to avoid conflicts.

若水般的淡然安静女子 2024-10-19 08:24:16

我发现执行此操作的一种方法是使用以下菜单命令:

Product -> Generate Output -> Generate Preprocessed File
Product -> Generate Output -> Generate Assembly File

这可能不完全是您想要的,但它将编译单个文件。

One way that I have found to do this is to using the following menu commands:

Product -> Generate Output -> Generate Preprocessed File
Product -> Generate Output -> Generate Assembly File

This may not be exactly what you want, but it will compile the single file.

囚你心 2024-10-19 08:24:16

当你构建一个项目时,xcode 运行编译命令。您可以检查日志、搜索文件并将该命令复制粘贴到终端上。它只会编译您在终端上复制/粘贴的文件。

When you build a project, xcode runs compilation command. You can check the log, search for your file and copy paste that command on Terminal. It'll compile only the file for which you copy/pasted on the terminal.

云醉月微眠 2024-10-19 08:24:16

如果您的文件是 C(或 C++)文件,则只需打开终端,转到文件所在的文件夹并输入

gcc -o outputFile inputFile.c

I am not familar with Objective-c that much, but GCC might work因为它只是 C 的超集,就像 C++ 一样。

希望这有帮助:)

If your file is C (or C++) file, then simply open your terminal, go to the folder in which the file resides and type

gcc -o outputFile inputFile.c

I am not familar with Objective-c that much, but GCC might work since it's only a superset of C, just like C++.

Hope that was helpful :)

终陌 2024-10-19 08:24:16

上的键盘快捷键 Cmd+K 已重新映射到 Xcode 4 上的 Cmd+B

Xcode 3 及之前版本 相同的行,Cmd+Return被重新映射到Cmd+R(如果你曾经使用过)

The keyboard shortcut Cmd+K on Xcode 3 and before has been remapped to Cmd+B on Xcode 4

Along the same lines, Cmd+Return was remapped to Cmd+R (in case you ever used that)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文