XCode 13 Not reporting accurate test Covarage

Following moving to Xcode 13 from 12.5, we are seeing our test coverage reported at ~1%, with only a small number of tests being reported in line with previous xcode builds.

Is this a know issue? Are there steps we can take to debug or mitigate this?

Nothing of note identified within the build log.

Xcode 13 Coverage:

Xcode 12 Coverage:

We are seeing the exact same issue in our projects, and I havn't found a solution/fix nor a reason yet. Just wanted to share so you know you are not the only ones in this situation.

We also see similar problems with generating coverage data (Xcode 13.1):

Failed to merge raw profiles in directory /Users/j<user>/Library/Developer/Xcode/DerivedData/XYZ-aoivlaczsouiakebozusuojanhvg/Build/ProfileData/<UUID> to destination /Users/<user>/Library/Developer/Xcode/DerivedData/XYZ-aoivlaczsouiakebozusuojanhvg/Build/ProfileData/<UUID>/Coverage.profdata: Aggregation tool '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata' failed with exit code 1

We have been waiting for new Xcode 13.x releases, but the problem is still here with Xcode 13.2.1.

I have tried to create a new dummy-project from scratch, and that project reports coverage correct in Xcode 13.2.1. I have tried to look through buildsettings in the dummy-project compared with the real projects we have, where coverage is not reported correct. But I have not been able to find the magic setting that is causing the failure of coverage.

It would be nice if an Apple Engineer can shed some light on what settings to try to change, or maybe throw in other ideas on what to try to provide some useful logging (besides the errors already shared in here that seems to point to the Aggregation tool). Since a new project from scratch seems to work fine, it's not possible to upload a small sample project to demo the problem.

Hi, Are you able to fix this issue? same we are facing in Xcode 13.1

In the release notes for Xcode 13.3 beta theres an interesting entry:

Xcode now collects code coverage data for processes that crash while running tests. (58496759)

Maybe this solves the issues (or some of them).

Hey, unfortunately we had to create a new project in order to do so.

We're facing the exact same issue with Xcode 13.3 on Apple Silicon Mac. It seems to be fine on Intel Mac though.

Disabling the code coverage for the pod repos inside pod project resolved this issue.

Add bellow script in Podfile to disable the code coverge

config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'

config.build_settings['swiftc'] = '$(SRCROOT)/SWIFT_EXEC-no-coverage'

Hi, Are you able to fix this issue? We get a similar issue in Xcode. 13.3 which the code coverage is 0 but Xcode 12.5 is fine.

Tried the script above, it didn't work.

My solution: If you have flag "GCC_GENERATE_TEST_COVERAGE_FILES=YES" specified in xcodebuild arguments, remove it in XCode 13. It seems like this will extract coverage data out of "*.xcresult" files in xcode 13.

We were able to find the root cause.

In our case, we were using 3rd party library (using Cocoapods). We changed the Mach-O type for that pod (inside the Pods.xcodeproj) to Static Library and the code coverage started working. By default, it was a Dynamic Library.

We spent a lot of time debugging this problem, but none of the suggestions we found helped.

it appears that one of our dependencies was a binary (xcframework), most probably distributed via older version of the XCode, after updating it coverage was back.

XCode 13 Not reporting accurate test Covarage
 
 
Q