似乎 xcodebuild 将所有内容打印到标准输出。
$ /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。有没有办法让 xcodebuild 向 stderr 打印错误和警告,除了1>&2
?
您可以尝试使用 -quiet 选项运行命令,如下所示。
# Do not print any output except for warnings and errors
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet
因此,您可以使用 -quiet 选项来管道警告和错误,并仅过滤您可以使用的错误2> ./错误.log
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet test.xcodeproj build -target test -configuration Debug -jobs 3 2> ./errors.log
还有其他工具可以检查,例如xcpretty and xc美化.
https://github.com/xcpretty/xcpretty https://github.com/xcpretty/xcpretty(我更喜欢这个)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)