如何在 Coverity 中使用 xcodebuild?

Posted

技术标签:

【中文标题】如何在 Coverity 中使用 xcodebuild?【英文标题】:How to use xcodebuild in Coverity? 【发布时间】:2017-03-27 09:35:55 【问题描述】:

为了在 Coverity 中分析我的 ios 应用程序,我尝试将 cov-buildxcodebuild 结合使用。

我运行的命令是:

cov-build --no-sip-check --dir intermediate xcodebuild -scheme scheme

构建成功,但没有发出任何文件:

** BUILD SUCCEEDED **

[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
 For more details, please look at: 
    /Users/bartk/Desktop/objctest/intermediate/build-log.txt
NL1MCL-506614:objctest bartk$ cov-analyze --dir intermediate 
Coverity Static Analysis version 8.7.0 on Darwin 16.4.0 x86_64

当我使用以下命令 cov-build --no-sip-check --dir itermediate clang -framework Foundation program.m 编译一个简单的 HelloWorld 程序时也会发生同样的情况,其中“不发出文件”。

当我查看objctest.build 文件夹时,所有目标文件都在那里。

当然,当我运行cov-analyze之后,它会出现以下错误:

Using 8 workers as limited by CPU(s)
Looking for translation units
Error: intermediate directory contains no translation units.

如何使 Coverity cov-build 与 Xcode 项目一起使用?

【问题讨论】:

【参考方案1】:

您是否使用cov-configure 配置了您的编译器?您很可能想要这种类型的东西:cov-configure --compiler gcc --comptype clangcc --template

由于 Apple 将其 Clang 称为 gcc,因此通常需要在此处明确指定 comptype,因为 MacOSX 上的 gcc 绝对不是 GCC。

【讨论】:

我使用了cov-configure --clang,这导致了我发布的输出。我也试过你的cov-configure --compiler gcc --comptype clangcc --template,但它给了我同样的错误。 我从您的编辑中看到您的二进制文件名为clang,所以cov-configure --clang 应该可以工作。您是否查看了构建日志以查看是否报告了任何问题以及这些问题是什么?

以上是关于如何在 Coverity 中使用 xcodebuild?的主要内容,如果未能解决你的问题,请参考以下文章

Coverity 工具静态扫描 QT 项目实践

使用 Coverity 使用 devenv 编译 C++ 项目时出错。 (cov-build.exe)

[TimLinux] Python3 Coverity zeep/SOAP 库使用示例

coverity和fortify有啥区别

coverity&fortify2--Null Dereference

coverity&fortify1--Poor Error Handling: Overly Broad Catch