2015-10-14 155 views
3

我有问题可以在Xcode 7中为某个iOS项目获取代码覆盖率报告。Xcode 7代码覆盖率报告不起作用

我按照这里给出的说明: http://mgrebenets.github.io/mobile%20ci/2015/09/21/code-coverage-for-ios-xcode-7/

三个项目我尝试中,有两个工作正常,但一个项目是让我头疼。当使用LLVM冠状病毒工具来生成从所收集的个人资料数据像这样的报告:

xcrun llvm-cov report -instr-profile Coverage.profdata MyAppBinary 

我收到错误消息:

error: Failed to load coverage: The file was not recognized as a valid object file 

我检查了“收集覆盖数据”为启用测试方案。我还检查了-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的试运行,“覆盖”选项卡在说“不覆盖数据”,而不是指示条。

任何想法我做错了什么?

+0

我试图遵循相同的文章,并有同样的错误。你有解决这个问题吗?如果是的话可以帮我吗?提前致谢!!! – Roma

回答

0

该项目的Xcode构建设置中的“Build Active Architecture Only”设置设置为“YES”。将其切换到“否”后,我现在可以运行llvm-cov命令。不过,数字并不会显示在Xcode中显示的数字。

0

我能够通过仅运行x86_64体系结构来解决问题。

使用ARCHS = “x86_64的” VALID_ARCHS = “x86_64的” 在你的xcodebuild联编命令

1

张贴我万一有人解决方案将需要它。 按照本文code coverage xcode 7 我做以下步骤:

  1. 安装的Cobertura插件
  2. 安装涂满插件
  3. 启用代码覆盖的项目(在架构偏好)
  4. 在詹金斯加入执行shell命令

/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

  • 最后但并非最不重要添加后生成步骤“publich的Cobertura报告” 的Cobertura XML报告模式 - 涂满报告/ cobertura.xml
  • 享受:)
  • 相关问题