如何使xcodebuild打印对stderr的编译错误和警告? [英] How to make xcodebuild print compile errors and warnings to stderr?

查看:67
本文介绍了如何使xcodebuild打印对stderr的编译错误和警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好像xcodebuild将所有内容都打印到stdout.

Seems like xcodebuild prints everything to stdout.

$ /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project test.xcodeproj build -target test -configuration Debug -jobs 3 2>err
 # xcodebuild stdout with bunch of warnings and errors

$ cat err
** BUILD FAILED **


The following build commands failed:
    CompileC _build/test.build/Objects-normal/x86_64/test.o /Users/me/test/test.cpp normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

那不能让我的IDE(QtCreator)正确解析输出.

That doesn't let my IDE(QtCreator) correctly parse the output.

实际上,clang将错误和警告打印到stderr.但是xcodebuild出于某种原因将所有内容重定向到strdout.除了 1&& 2 之外,是否有办法使xcodebuild向stderr打印错误和警告?

And clang, actually, prints errors and warnings to stderr. But xcodebuild redirects everything to strdout for some reason. Is there a way to make xcodebuild print errors and warnings to stderr except 1>&2?

推荐答案

是否可以尝试使用-quiet选项运行命令,如下所示.

Can you try running the command with -quiet option as follows.

# Do not print any output except for warnings and errors
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet

因此,您可以仅使用-quiet选项传递警告和错误,并且可以使用 2>仅过滤错误../errors.log

So you can just pipe warnings and errors by using -quiet option and to filter only error you can use 2> ./errors.log

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet test.xcodeproj build -target test -configuration Debug -jobs 3 2> ./errors.log

还有其他检查工具,例如 xcpretty xcbeautify .

There are other tools to check such as xcpretty and xcbeautify.

https://github.com/xcpretty/xcpretty (我更喜欢)

这篇关于如何使xcodebuild打印对stderr的编译错误和警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆