2015-10-14 59 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
  • 享受:)
  • 相關問題