Code coverage generation fails on M1 Mac when excluding Arm64 architecture

Hi Everyone, our project has a few vendor libraries that don't support the M1 architecture when building for the simulator, so we have to exclude the arm64 arch in order to compile.
However, when we do this, generating code coverage will fail for all targets with the following message:

Code Block
Failed to generate coverage for target 'UnitTests.app' at paths ("/Users/xxxx/Library/Developer/Xcode/DerivedData/UnitTests-dzyobvtkdsjkmlbzpenutqaqgbbl/Build/Products/Debug-iphonesimulator/UnitTests.app/UnitTests"): No object file for requested architecture

Resulting in coverage data missing for our project.

Has anyone else encountered this?
Known issue?
Any workarounds?


Thanks in advance for any help.


Replies

Yep, also encountered the same empty coverage results as you (M1, excluded arm64). Not resolved as of Xcode 12.5 beta 3.

Same issue on M1 mini, Xcode 12.5 release version. 😦

Same issue!!

Any updated from Apple engineers??

Fixed!!!!

In addition to reviewing the architecture configurations that we have surely done a thousand times and see that they were useless.

I decided to test it with the Xcode started with Roseta and I returned to have my coverage report.

  • The main issue is still happening in Xcode 13 Beta, I've opened a radar for the issue as well : FB9088539

    @cplaza It's a workaround, but I still wouldn't call it fixed - it feels like fundamentally something's amiss with code coverage generation.

  • Well fun thing will happen in one year time, when transition to AS will be complete and there will be no more Rosetta to use... Really this should get fixed. Another workaround is to run tests on real device - that way I get all coverage.

  • Sorry but you've not fixed it, you've found a workaround by running Xcode under Rosetta x86_64 emulation mode. This means Xcode will be very slow to build and use in general. If you want to generate a one-off code coverage report without running the whole of Xcode under Rosetta, you could use arch -x86_64 xcodebuild test -scheme {MyApp}-Package -destinationplatform="macOS" -enableCodeCoverage YES and then open the resulting xcresult file which will be added to Xcode's "Report Navigator".

Add a Comment

Ok I think I have found a problem inside my project: some of the targets had excluded arm64 architecture so I removed that. Also update any cocoapods you have, we had some before that has set arm64 as excluded architecture, but now there is none that has that setting, so coverage is working.

Same Issue on M1, and here is a temporary solution.

The cause of this issue is M1. Before testing, Select My Mac (Rosetta) rather than My Mac on top-left selector of Xcode mid-pane.

Then everything works fine.

  • Thanks!

    Small addition: if your project fails to compile due to use of platform-specific frameworks (UIKit in my case), try switching to My Mac (Mac Catalyst, Rosetta).

  • This worked for me, thanks a lot.

Add a Comment

Same issue here on my M1 Mac mini. Works when testing under Rosetta. Super lame Apple!

Still happening, and still no movement on my bug report.

FB9088539

I'd like to start migrating my build nodes to M1 Mac minis, but without code coverage generation it grinds our build process to a halt.

KaosDG, I took a look at your bug report and it’s unclear whether your setup (where you explicitly exclude an architecture) is something that we support. I recommend that you open a DTS tech support incident so that you can discuss this with DTS’s tool’s expert.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • @eskimo

    I created a package completely from scratch using default options with no dependencies and it still has the error.

    The most obvious explanation would seem to be that code coverage is broken for ARM64 and needs to be fixed. I'm going to raise a bug with my test project attached.

    By the way and off topic: "share and enjoy" is the slogan of the loathsome Sirius Cybernetics Corporation whose marketing department (who came up with the phrase) Douglas Adams characterised as "a bunch of mindless jerks who will be the first against the wall when the revolution comes". Knowing the etymology of the phrase, I find it quite triggering in the context of being used by an employee of a large technology company in their support forums.

    Also, how do you do paragraphs?

Add a Comment

I'm going to raise a bug with my test project attached.

Thanks. Please post the bug number once you’re done.

Knowing the etymology of the phrase, I find it quite triggering in the context of being used by an employee of a large technology company in their support forums.

I’m sorry about that but I’m not going to change my signature. Rest assured that I’m using the phrase ironically.

Also, how do you do paragraphs?

In normal posts? Or in comments?

In normal posts you just use standard Markdown syntax. In comments… well, I rarely use comments because they have serious usability issues (r. 80839588).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This has been fixed in Xcode 13.2.

Wow this is great news - seeing coverage now.

Unfortunately, this has broken tests I have with StoreKitTest framework :(