In a nutshell: I have a Swift package with Objective-C code that depends on another package with Swift code. When building it without code coverage enabled, everything builds fine. When code coverage is turned on, I get undefined symbols. Ideally I'd rewrite this code to Swift, but that's not feasible at the moment.
StackOverflow mentions adding -fprofile-instr-generate to linker flags, but I don't know if that is even possible in a package manifest (or at least without using unsafe flags).
I've run into this issue too. I don't know if it's solvable, and adding that flag for standard builds seem problematic.
What I've found is this issue seems to happen when SwiftPM and possibly Xcode decide to build as a dylib. When my libraries are built as static libraries I don't get this error.
I'll be opening a bug with Apple when I get a chance as I'm not sure if the bug is in SwiftPM or Xcode.
I was able to work around this by using a local binary Swift package. Thankfully the package that was causing me problems (PLCrashReporter) provides an xcframework in their Github releases, and Xcode prefers local packages to remote ones when resolving dependencies.