iosswiftswiftuitensorflow-litexcframework

How to Hide Internal Dependencies in Swift Framework's .swiftinterface File?


I’m building a Swift framework that uses internal dependencies like Alamofire, Lottie, and TensorFlowLite. These are only needed within the framework itself, not by the users of the framework.

But when I build the framework, these dependencies show up in the .swiftinterface file, which seems to imply that users need to have them too.

What’s the best way to ensure these internal dependencies stay hidden from the framework’s public interface and that users don’t need to install them?

Thanks!

SwiftInterface


Solution

  • This seems to be a similar situation to this Swift Forums post. As one of the comments there suggest, you can use a @_implementationOnly import to import the internal dependencies.

    From the underscored attributes reference,

    Used to mark an imported module as an implementation detail. This prevents types from that module being exposed in API (types of public functions, constraints in public extension etc.) and ABI (usage in @inlinable code).