对于某个iOS项目,我在Xcode7中使用代码覆盖率报告时遇到了问题。
我按照这里给出的说明操作:http://mgrebenets.github.io/mobile%20ci/2015/09/21/code-coverage-for-ios-xcode-7/
在我尝试的三个项目中,有两个工作得很好,但有一个项目让我头疼。使用llvm-cov实用程序从收集的配置文件数据生成报告时,如下所示:
xcrun llvm-cov report -instr-profile Coverage.profdata MyAppBinary 我收到错误消息:
error: Failed to load coverage: The file was not recognized as a valid object file我检查了测试方案是否启用了"Gather coverage data“。我还检查了-fprofile-instr-generate和-fcoverage-mapping编译器选项是否传递给了clang。
文件大小和类型在我看来也是有效的:
ilMac:llvm-cov-test ilja$ ls -la
total 61976
drwxr-xr-x 4 ilja staff 136 14 Okt 21:53 .
drwxr-xr-x+ 75 ilja staff 2550 14 Okt 16:31 ..
-rw-r--r-- 1 ilja staff 1797416 14 Okt 21:53 Coverage.profdata
-rwxr-xr-x 1 ilja staff 29932040 14 Okt 16:32 MyAppBinary
ilMac:llvm-cov-test ilja$ file Coverage.profdata
Coverage.profdata: data
ilMac:llvm-cov-test ilja$ file MyAppBinary
MyAppBinary: Mach-O universal binary with 2 architectures
MyAppBinary (for architecture i386): Mach-O executable i386
MyAppBinary (for architecture x86_64): Mach-O 64-bit executable x86_64我还注意到测试运行的Xcode中的" coverage“选项卡显示的是"No coverage data”,而不是指示栏。
知道我做错了什么吗?
发布于 2016-06-28 17:33:37
发布我的解决方案,以防有人需要它。遵循本文code coverage xcode 7,我完成了以下步骤:
/usr/bin/xcodebuild test -workspace MyApp.xcworkspace -scheme MyAppTests -configuration DebugMyApp -destination "platform=iOS Simulator,OS=9.3,name=iPhone 6" -enableCodeCoverage YES
构建一个主干
slather coverage \ --input-format profdata \ --cobertura-xml \ --ignore "../**/*/Xcode*" \ --output-directory slather-report \ --scheme MyAppTests \ --workspace MyApp.xcworkspace \ MyApp.xcodeproj
发布报告和最后但并非最不重要的构建后步骤“ cobertura
发布于 2015-10-19 20:48:26
该项目的Xcode构建设置中的"Build Active Architecture Only“设置为"YES”。在将其切换为"NO“之后,我现在可以运行llvm-cov命令。不过,数字与Xcode中显示的数字并不相同。
发布于 2015-11-26 14:11:01
我能够通过只使用x86_64架构来解决这个问题。
在xcodebuild命令中使用ARCHS="x86_64" VALID_ARCHS="x86_64"
https://stackoverflow.com/questions/33134535
复制相似问题