Unit tests don't see the framework they're supposed to test although they're in same SwiftPM target

175 Views Asked by At

I'm migrating an Objective-C framework to build with Swift Package Manager, but when I build it using xcodebuild -scheme MyFramework -workspace ., SwiftPM complains:

/Users/uli/Programming/apple/MyFramework/MyFrameworkTests/MyFrameworkTests.m:4:9: module 'MyFramework' not found
@import MyFramework;
 ~~~~~~~^~~~~~~~~~~~~~~

I have verified that the .testTarget has a dependencies: ["MyFramework"] entry.

1

There are 1 best solutions below

0
uliwitness On

Found the solution due to a colleague's tip. The error message is just misleading. I thought it was unable to find the build product, when it really found the build product, but thought it was empty because I forgot to set up public headers for the Swift Package:

.target(
    name: "StreamUtilities",
    ...
    publicHeadersPath: "include",
    ...

and to move all public headers into an include subfolder of the target's folder.