使用 xcode 构建时如何显示编译器输出或自定义构建步骤输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5420068/
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
How to display compiler output or custom build steps output when building with xcode?
提问by sorin
How can I see the output from the compiler of from the custom build steps (pre-action or post-action)?
如何查看自定义构建步骤(操作前或操作后)的编译器输出?
采纳答案by Jonah
Pre-action output at least appears in system.log and is visible in Console.app.
Pre-action 输出至少出现在 system.log 中,并且在 Console.app 中可见。
回答by Codo
You'll find (and you can watch during the build) the complete build output in the Log Navigator. That's the right most icon of the small icons just below the Run and Build buttons.
您将在 Log Navigator 中找到(并且可以在构建过程中观察)完整的构建输出。这是运行和构建按钮下方小图标中最右侧的图标。
回答by Nikola Lajic
EDIT:as pointed out in the comment below this answer only works for Build phase scripts, not pre action and post action scripts.
编辑:正如下面的评论中所指出的,这个答案只适用于构建阶段脚本,而不适用于动作前和动作后脚本。
In Xcode 8 you need need to select your latest build in "Navigator -> Report Navigator". In the main area you will be able to see the complete build log including your output.
在 Xcode 8 中,您需要在“Navigator -> Report Navigator”中选择最新版本。在主要区域,您将能够看到完整的构建日志,包括您的输出。
Here is a simple "Hello world" echo
这是一个简单的“Hello world”回声
回答by Joshua Nozzi
Per my answer here ( Is it normal for Xcode not to detect if a pre-action failed?) this is an issue that's been discussed in the dev forums. Pre-/post-action script non-zero status doesn't seem to have an affect, nor does the output seem to make it into any logs.
根据我在此处的回答(Xcode 不检测预操作失败是否正常?)这是开发论坛中讨论过的问题。动作前/动作后脚本非零状态似乎没有影响,输出似乎也没有进入任何日志。
回答by BadPirate
So I figured out a way to both:
所以我想出了一种方法:
- Show output from pre-build scripts
- Stop the build script in the case of a build error
- 显示预构建脚本的输出
- 在构建错误的情况下停止构建脚本
The basic concept is to send all output from the build event to various files, and then present that output as a part of a target build script (which does show it's output and can be exited or canceled).
基本概念是将构建事件的所有输出发送到各种文件,然后将该输出作为目标构建脚本的一部分呈现(它确实显示了它的输出并且可以退出或取消)。
Warning Hacks be near
警告黑客就在附近
Setup a build script that automagically handles pumping the output to 2 different files... 1 for the regular logs, and one for stderr. Or use mine(I posted on my blog because it seems stack overflow code detection sucks at shell scripts.)
设置一个构建脚本,自动处理将输出泵送到 2 个不同的文件...... 1 个用于常规日志,一个用于 stderr。或者使用我的(我发布在我的博客上,因为看起来堆栈溢出代码检测在 shell 脚本中很糟糕。)
Then you should call that script in the scheme prebuild phase like so:
然后您应该在方案预构建阶段调用该脚本,如下所示:
"${PATH_TO_LOG_SCRIPT}/log_prebuild.sh" "${PATH_TO_PREBUILD_SCRIPT_TO_EXECUTE}/scriptToExecute.sh" 2> "${SOURCE_ROOT}/build/prebuild_error.log"
Then you need to setup a script in prior to the compile phase in the target build phases that checks for the presence of those files, dumps them to the logs, and interrupts the build if there was a failure. Or you could again use mine
然后,您需要在目标构建阶段的编译阶段之前设置一个脚本,以检查这些文件是否存在,将它们转储到日志中,如果出现故障则中断构建。或者你可以再次使用我的
Then build and cross your fingers :)
然后建立并交叉你的手指:)