Are Swift+Objc static libraries supported by Xcode? Are Swift static libraries even supported?

We have an SDK that we vend as both a dynamic framework and static library. We recently added our first Swift file to it, and we are unable to access the Swift code from Objc when building it as a static library:

'MySDK/MySDK-Swift.h' file not found

The same code works when building as a dynamic framework. Is there something else I need to do to enable this to work? Or is it just not supported at all?

Have you considered an .xcframework instead of a static library? I believe these are supported by SwiftPM as well.

That is how we vend the dynamic framework. Do xcframeworks also support static linking? My understanding is they do not

We have a niche use case where static linking is favorable for some of our customers

Yes: Creating a multiplatform binary framework bundle | Apple Developer Documentation

To include a static library file (.a file), replace -framework with -library in the command above.

1 Like

TIL! We will experiment with this :eyes: (In the meantime, I am curious about my question on a technical level if anyone knows the answer)

My guess is that this is a modules thing. Maybe you could find a suitable place to put the .modulemap, but you’re swimming upstream.

1 Like

“I love module maps so much!”, he said with heavy sarcasm

You could combine the 2 types: Configuring your project to use mergeable libraries | Apple Developer Documentation