Xcode doesn't gather code coverage from packages when set to "some targets"

I've reported this as FB7724987, but wanted to know if there are any workarounds for now, since it'll likely take some time before a new stable version of Xcode is even available (and that assumes it will fix this).

I have an Xcode project that consists of an app target and some local packages (there are also some Cocoapods frameworks, but that's not relevant). When I set the test plan to gather code coverage from "some targets" and include the local packages in that, they simply don't show up in the test results. When I set coverage to "all targets", they do show up. This seems like a bug that might prevent us from going all-in on SPM.

The only "workaround" I could think of so far would involve generating projects from all the packages and then linking them into the app instead (nested projects don't have this problem), but that seems like an awful lot of work for getting code coverage data.

Randomly pinging @eskimo - do you know if anyone who hangs out here could help?

No, sorry. My advice from DevForums still applies: If you don’t get help via informal channels, it’s time to open a DTS tech support incident.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

I was facing the same problem and ended up writing a script that modifies the resulting code coverage json. Not sure if this is exactly the need you have, but it's the specific problem I faced (wrong code coverage report) and fixed it by writing this script: Xcode doesn’t gather code coverage from packages when set to “some targets”. This script fixes this. Also see https://forums.swift.org/t/xcode-doesnt-gather-code-coverage-from-packages-when-set-to-some-targets/37220 · GitHub

Terms of Service

Privacy Policy

Cookie Policy