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.
  • We have a project which has both UI and Unit tests.

  • Uses fastlane.

  • Has CI/CD implementation using Jenkins which runs on an aws ec2 instance.

  • Quite recently we moved to Xcode12 (I know!!! However, better late than never)

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)

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

Then we run the test using

Code Block
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.
Code Block
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.

Did you find a solution for it? Having the same problem, afterwards the test crashs

Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test crashed with signal abrt.

[16:01:26]: ▸ warning: <DerivedData_Path>/Build/ProfileData/<Some_UUID>/<Filename>.profraw: Invalid instrumentation profile data (file header is corrupt)

[16:01:26]: ▸ error: No profiles could be merged.

[16:01:26]: ▸ Testing failed:

[16:01:26]: ▸ 	<Some_Package>Tests:

[16:01:26]: ▸ 		xctest (20781) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test crashed with signal abrt. If you believe this error represents a bug, please attach the result bundle at <Project_Path>/fastlane/test_output/<Filename>.xcresult))
xcodebuild fails to generate Coverage.profdata on xcode12, fails with error 'error: No profiles could be merged.'
 
 
Q