如何解决如何使xcodebuild打印编译错误和警告到stderr?
好像xcodebuild将所有内容都打印到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)正确解析输出。
实际上,clang将错误和警告打印到stderr。但是xcodebuild出于某种原因将所有内容重定向到strdout。除了1>&2
之外,是否有办法使xcodebuild向stderr打印错误和警告?
解决方法
您可以尝试使用-quiet选项运行命令,如下所示。
# Do not print any output except for warnings and errors
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet
因此,您可以仅使用-quiet选项传递警告和错误,并且可以仅使用 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 。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。