I open it in Xcode, and I have "Gather coverage for all targets" selected in build scheme.
My tests run and succeed without an issue. However, the code coverage is not gathered. In logs I see such warning:
Failed to generate coverage for target 'MyPackageTests' at paths (
"/Users/[...]/Library/Developer/Xcode/DerivedData/MyPackage-cfufflstgcguakceoeffzdilbbjq/Build/Products/Debug-iphonesimulator/MyPackageTests.xctest/MyPackageTests"
): No object file for requested architecture
My setup:
MacBook Pro M1
Xcode 12.4 (12D4e)
I tried to run tests on my old MacBook Pro (Late 2016) with Intel processor and the code coverage was gathered without an issue, so it looks like the problem is related to Apple Silicon architecture.
Is there something I can do to make the code coverage gathering work on M1 Mac?
Thanks @NeoNacho for confirming I am not the only one experiencing this issue. I couldn't find any reports of similar problems. I hope it will be fixed soon Is there any resource I can follow to track the issue status?
Since this is an Xcode issue, not really. You could file your own bug, but since it would be a duplicate, updates would only be pull-based (you could manually ask for an update of the status of the dupe).
Do you know if they have an open radar for this one @NeoNacho? I'm still experiencing on Xcode 13 with silicon Macs. Is this because I have excluded arm-64 from the build?
Error occured while exporting xccovreport from xcresult
Meanwhile you might as well build (and test ) for Mac(Rosetta) target: code coverage will work. Unfortunately this might also lead to some additional battery drain on your laptop.
Unfortunately that only works for packages that can run on Macs. We have some iOS-only packages and there we have to use an Xcode project to get this to work.
Let's hope this gets fixed now that more developers start using Apple Silicon machines...