Pramod M
Pramod M

Reputation: 41

Xcode UI Tests : xcodebuild fails to generate Coverage.profdata on xcode12, fails with error 'error: No profiles could be merged.'

Here is how we are setup while facing the issue.

Problem statement:

After moving to xcode12, the jenkins pipeline is unable to generate the Coverage.profdata file which in turn will be used by Slather to derive code coverage metrics. Yes, did not happen when running xcode11.

We are using the xcodebuild command after pointing it to the appropriate command line tool version (in this case it is 12.4).

First we build the app using (after getting the simulator ID)

xcodebuild build-for-testing -workspace Example.xcworkspace -scheme ExampleUITests -derivedDataPath ./derivedData -destination 'platform=iOS Simulator,id=<simulator_id>'

Then we run the test using

xcodebuild test-without-building -workspace Example.xcworkspace -scheme ExampleUITests -enableCodeCoverage YES -destination 'platform=iOS Simulator,id=<simulator_id>' -derivedDataPath ./derivedData

All the UI tests run successfully but end up with the following statements when the test suite completes.

warning: <Path_to_derived_data>/Build/ProfileData/<Some_UUID>/<Filename>.profraw: Invalid instrumentation profile data (file header is corrupt)
error: No profiles could be merged.

P.S: This is not happening on my local machine. Only on the mac in the Jenkins ec2 instance.

Upvotes: 1

Views: 1799

Answers (1)

asifmohd
asifmohd

Reputation: 999

We faced a similar issue. We were also using fastlane.

And the fix which worked for us was to ensure we delete any artifacts from the previous build. The situation you've described is quite similar to situation we faced. The first run for unit tests generates a few coverage artifacts, after which executing UI tests also generates coverage artifacts and then xcov/slather is unable to parse these artifacts.

Therefore, can you check if deleting the Logs/Test folder in derived data helps? If it doesn't try clearing derived data entirely and then check if that helps resolve the issue on CI.

See related threads on xcov

Upvotes: 0

Related Questions