Hi all,

I'm building a Swift Package (ASDK), exposed via SPM that depends on another swift package (BSDK), added as a dependency in the Package.swift. My dependency graph looks like the following:

ClientApp -> ASDK -> BSDK.

Is there a way (and what's the best approach if multiple), to expose a struct (e.g. Person) to the ClientApp without importing BSDK and only importing ASDK? Thanks for any help.

Option 1. In ASDK add @_exported import BSDK. Then all public types from it will be available seamlessly.

Option 2. Define public typealias Person = BSDK.Person if you want to expose only certain types.

2 Likes

Thanks so much for the prompt reply. Are there any downsides to using these approaches? For example, I know that:

  • Option 1: @_exported import is considered experimental.
  • Option 2: Might cause problems if ASKD becomes a framework and BSDK isn't.

Any additional downsides that I might be missing? Or thoughts on the cons I mentioned? Thanks again.

Yeah, but lots of packages (with swift-foundation among them) are using it so far, that I wouldn't be so much concerned about it experimental status.

I am not aware, but I as well might be not the best source of pitfalls of re-exporting, so maybe others jump in with their experience.

1 Like

I would just like to add that @_exported does not work well with declarations marked with @_spi