如何编译单个文件 Xcode 4?
虽然我曾经在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
单文件编译的常见要求是检查语法错误。 (至少对我来说)。由于 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.
该命令已移至“执行操作”子菜单。查看
“要将 Cmd+K 分配给它”下,转到
“编译文件”,您可以在其中分配密钥。 Cmd+K 现在默认分配给 Clear Console,因此请务必删除该绑定以避免冲突。
The command has been moved to the Perform Action submenu. Look under
To assign Cmd+K to it, go to
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.
我发现执行此操作的一种方法是使用以下菜单命令:
这可能不完全是您想要的,但它将编译单个文件。
One way that I have found to do this is to using the following menu commands:
This may not be exactly what you want, but it will compile the single file.
当你构建一个项目时,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.
如果您的文件是 C(或 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
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 :)
上的键盘快捷键 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)