简体   繁体   English

xcode 4:如何添加自定义编译器?

[英]xcode 4: how can I add a custom compiler?

Xcode seems to allow specifying a custom compiler for source files via the Build Rules tab (copy the system C rule to the target, select "Custom Script". Just for testing the concept, I wrote echo $* as the script. However it doesn't really run that script (no output is sent to the console); the end result is that no file gets built, so later I get a link error. Xcode似乎允许通过 Build Rules 选项卡为源文件指定自定义编译器(将系统 C 规则复制到目标,选择“自定义脚本”。只是为了测试这个概念,我写了echo $*作为脚本。但是它没有'没有真正运行该脚本(没有输出发送到控制台);最终结果是没有构建文件,所以后来我收到链接错误。

Am I using it wrong?我用错了吗? What's the correct way of using a custom compiler in Xcode 4.x?在 Xcode 4.x 中使用自定义编译器的正确方法是什么?

I tried your example.我试过你的例子。 The script would not run unless I added an output file to the Output Files table for the build rule.除非我将输出文件添加到构建规则的输出文件表,否则脚本不会运行。 Then the script ran, but the results appear in the build transcript instead of the console.然后脚本运行,但结果出现在构建记录中而不是控制台中。 Open the log navigator by choosing View > Navigators > Show Log Navigator.通过选择“查看”>“导航器”>“显示日志导航器”来打开日志导航器。 Select your build from the log navigator to open the build results window.从日志导航器中选择您的构建以打开构建结果窗口。 There should be a run custom shell script step in the build results window.构建结果窗口中应该有一个运行自定义 shell 脚本步骤。 On the right side of the step is a small button with several horizontal lines.在台阶的右侧是一个带有几条水平线的小按钮。 Click that button to show the build transcript.单击该按钮以显示构建脚本。

If you want to use a custom compiler on some of the files in your project, you may find it easier to add a Run Script build phase to your target and add the files you want to compile to the Run Script build phase.如果您想对项目中的某些文件使用自定义编译器,您可能会发现将运行脚本构建阶段添加到目标并将要编译的文件添加到运行脚本构建阶段会更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM