Archiving a Swift SDK with SPM Dependencies for XCFramework Distribution

Hello,

I’m building a Swift-based SDK (using SwiftUI) that will be distributed as a single .xcframework, and consumed by a React Native application. The SDK has multiple internal module dependencies (e.g., Essentials, CoreModels, CoreRepository), each of which is currently implemented as a local Swift Package (SPM).

When I attempt to archive the main SDK framework using xcodebuild archive with BUILD_LIBRARY_FOR_DISTRIBUTION=YES, the archive process fails during SwiftEmitModule for these SPMs. I understand this likely relates to module stability requirements for .xcframework distribution.

My key question: Is it mandatory to convert all Swift Packages (SPMs) into Xcode framework targets in order to successfully archive and bundle them into a distributable .xcframework?

Or alternatively, is there a recommended approach to make Swift Packages archive-compatible for use in a compiled, closed-source SDK, without converting them into Xcode framework targets?

Awaiting your guidance.

Archiving a Swift SDK with SPM Dependencies for XCFramework Distribution
 
 
Q