1

I am unable to generate the code coverage data when the the workspace is built with custom XCODE_CONFIGURATION_BUILD_DIR.

We run the xcodebuild commands to build the workspace with a XCODE_CONFIGURATION_BUILD_DIR, so that multiple jenkins CI jobs won't overwrite the build output of other jobs which are also running concurrently.

When we run the tests for a build generated this way and try to get the code coverage report, the command fails with the below error.

jenkins$ xcrun xccov view *.xccovreport

Errors: Error Domain=IDEFoundationErrorDomain Code=14 "Failed to merge raw profiles in directory /Users/jenkins/Library/Developer/Xcode/DerivedData/XXXXXX-buggtqumttnpjvejnbfhulhqcvno/Build/ProfileData/bff950eda0f75b2dbadb3ce08510474b4667ac82 to destination /Users/jenkins/Library/Developer/Xcode/DerivedData/XXXXXX-buggtqumttnpjvejnbfhulhqcvno/Build/ProfileData/bff950eda0f75b2dbadb3ce08510474b4667ac82/Coverage.profdata: No profile data files were written to '/Users/jenkins/Library/Developer/Xcode/DerivedData/XXXXXX-buggtqumttnpjvejnbfhulhqcvno/Build/ProfileData/bff950eda0f75b2dbadb3ce08510474b4667ac82'" UserInfo={NSLocalizedDescription=Failed to merge raw profiles in directory /Users/jenkins/Library/Developer/Xcode/DerivedData/XXXXXX-buggtqumttnpjvejnbfhulhqcvno/Build/ProfileData/bff950eda0f75b2dbadb3ce08510474b4667ac82 to destination /Users/jenkins/Library/Developer/Xcode/DerivedData/XXXXXX-buggtqumttnpjvejnbfhulhqcvno/Build/ProfileData/bff950eda0f75b2dbadb3ce08510474b4667ac82/Coverage.profdata: No profile data files were written to '/Users/jenkins/Library/Developer/Xcode/DerivedData/XXXXXX-buggtqumttnpjvejnbfhulhqcvno/Build/ProfileData/bff950eda0f75b2dbadb3ce08510474b4667ac82'}

Version/Build: Version 10.1 (10B61)

durgasunil
  • 98
  • 9

2 Answers2

0

Found this thread on Github

The issue was: generating coverage for a Static Library fails, but not for a Dynamic Library.

So check if it works, changing on pbxproj:

- MACH_O_TYPE = staticlib;
+ MACH_O_TYPE = mh_dylib;

enter image description here

And it really generated coverage successfully on my sample framework.

Carlos Ricardo
  • 2,058
  • 25
  • 32
0

The solution which worked for me was, I have changed the Mach-O-Type from Executable to Static Library.

  1. With the option Dynamic Library also, the coverage report was generating but the build was failing.
  2. Another option was to set the test target as Static Library and Main Target as Executable. Build Succeeded and able to see the coverage for multiple targets.

Xcode Version : 13.4

enter image description here

swiftache
  • 60
  • 9