As of Oct 2020, the only way to distribute Swift Packages in a binary format is to create an XCFramework and then wrap it in a Swift Package as a binary target. That is alright in itself, except there is no obvious way to create XCFramework from Swift Package source in the first place.
According to Apple Documentation, one should first build frameworks for different platforms using
xcodebuild archive and then use
xcodebuild -create-xcframework to wrap those frameworks into XCFramework. The problem is, this does not work with Swift Package schemes. The generated archive is not a framework and thus it is incompatible with
xcodebuild -create-xcframework. Check this gist for the detailed example.
In an attempt to work around that problem, one might try using
swift package generate-xcodeproj to generate Xcode project first and then follow the steps from the Apple Documentation to archive the frameworks and wrap them into
XCFramework, however that fails hopelessly when a package contains resources and even crashes if a package has other binary dependencies. Generated Xcode project neither generates the resources accessor
Bundle.module, nor does it create resource bundle. Binary dependencies fail gracefully - not.
Consequently, one will probably reach out to the community in hope of find a solution and stumble upon an amazing tool swift-create-xcframework, but only to find out that it is built on top of the same code as
swift package generate-xcodeproj and thus not supporting resources and crashing on binary dependencies.
Finally, when hope is all but lost, I am reaching out here. Is there a solution to this problem? Has anybody found a way to build XCFrameworks from Swift Packages without maintaining parallel Xcode project files?