Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What could cause code coverage enabled builds to fail?

Summary

I'm trying to get a code coverage report from my project. However when I try to build and run tests, there is no CodeCoverage folder created in the derived data folder.

How am I trying to do this?

I am running xcodebuild as follows:

xcodebuild \ -workspace <some_workspace> \ -scheme <some_scheme> \ -destination <some_destination> \ -derivedDataPath <some_path> \ -enableCodeCoverage YES \ build test

What is the problem?

For my workspace/project it fails at the very end with a line:

xcodebuild: error: Failed to build workspace <some_workspace> with scheme <some_scheme>. Reason: Could not determine bundle identifier for <some_test_target>'s TEST_HOST: "<some_path>/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/<some_product>.app"

At first it seemed directly linked to the TEST_HOST issue, but that's not the case here.

There is simply no CodeCoverage folder:

<some_path>/Build/Intermediates/CodeCoverage

What have I tried?

I tried the same with a clean new project, same running the same xcodebuild command, which succeeds. Within the Build/Intermediates/ folder exists the CodeCoverage folder.

However, in my own project, which is more complex, the Build/Intermediates/ folder contains a bunch of *.build folders (related to the app and the various frameworks, HockeySDK.build for example) and PrecompiledHeaders but no CodeCoverage folder.

When looking through the output of xcodebuild I never see a reference to the CodeCoverage folder for my project. However, for the test project, the first mention is at:

Write auxiliary files /bin/mkdir -p /<some_path>/Build/Intermediates/CodeCoverage/Intermediates/<some_project>.build/Debug-iphonesimulator/<some_project>.build/Objects-normal/x86_64

For my project I see:

Write auxiliary files /bin/mkdir -p /<some_path>/Build/Intermediates/<some_project>.build/Debug-iphonesimulator/<some_project>.build/Objects-normal/x86_64

Workaround

Something else that seemed to 'trick' it into working is to set the Host Application to None. After doing this it builds and tests, but tests fail due to the lack of host. However, this causes the CodeCoverage folder to be created, and if the Host Application is correctly set again, running the build and tests works fine, with a code coverage report produced.

like image 863
Vamos Avatar asked Oct 17 '16 14:10

Vamos


1 Answers

You have to assure the package name is equal in all configurations. Xcode modifies it in case you are using unsupported characters. For instance Xcode replaces "-" with "_".

In all configurations, go to:

Project -> Build Settings -> Product Module

and set the exact same name without spaces.

like image 192
shallowThought Avatar answered Oct 19 '22 04:10

shallowThought