I had a similar error in my project (using Xcode 13.2.1 on an M1 mini), but only in the unit test target associated with my program (a command line tool rather than an application). Oddly, the error pointed to the @testable import <program_name> line in one of my unit test source files, and only when the selected scheme was the one for the unit test target. My project does include a number of Swift packages.
Searching the Internet for the text of the error message led me here; I tried the approved answer (explicitly setting the architecture to "x86_64 arm64", and it seemed to work for me.
However, in subsequent experimentation I found that it appeared to be sufficient (in my case, anyway) to ensure that the Architecture was set to "$(ARCHS_STANDARD)" directly on the project, instead of inheriting the value from the "macOS Default".
Topic:
Programming Languages
SubTopic:
Swift
Tags: