Vamos Vamos - 3 months ago 25
iOS Question

What could cause code coverage enabled builds to fail?


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:


What have I tried?

I tried the same with a clean new project, same running the same
command, which succeeds. Within the
folder exists the

However, in my own project, which is more complex, the
folder contains a bunch of
folders (related to the app and the various frameworks,
for example) and
but no

When looking through the output of
I never see a reference to the
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


Something else that seemed to 'trick' it into working is to set the
Host Application
. After doing this it builds and tests, but tests fail due to the lack of host. However, this causes the
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.


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.