linker failing for unit tests in multiplatform project

I have a multiplatform project in Xcode 13.3.1, but when I try to run a unit by clicking the diamond in the gutter, the linker fails. From the link line in the log, it looks as if it isn't even linking with my app at all.

I also noticed that I had to put in my own

@testable import NameOfMyApp

instead of Xcode generating that line like it does for single-platform projects, so that makes me wonder if this something extra i need to do since this project is multiplatform?

Everything compiles fine, but the linker seems to be forgeting to link with my app...

Post not yet marked as solved Up vote post of remsleep Down vote post of remsleep
1.1k views
  • Any progress on this? I'm having similar problems. I have a local Swift package. It links fine with the app, and the app runs. But when I try to run the macOS tests I get linker errors that it doesn't see symbols from that package. Something is screwed up with multiplatform projects. (Xcode 13.4.1)

Add a Comment

Replies

If it's the same problem I had, it's this: with multiplatform projects, those tests that Xcode creates for you are not unit tests, but "UI Tests". They do not link the same. You need to create more targets if you want to do unit testing. You'll see the Unit Test Bundle choice when you create a new target. I gave mine a similar name to the project template's UI Tests. So now I have "Tests macOS" and "Unit Tests macOS". The first is the UI Test bundle target created by Xcode. The second is my unit testing bundle. Linking works normally in there. .