I’m developing an iOS SDK and I want to distribute it as an XCFramework.
My requirements:
- The SDK code must be hidden (binary-only).
- Some dependencies (e.g., OpenSSL) are manually added as frameworks to the target, embedded & signed.
- Some libraries are added via SPM.
In all 3rd party imports inside my SDK, I use:
@_implementationOnly import SomePackage
to avoid exposing them in the public interface.
I am trying to archive the SDK using xcodebuild archive to produce an XCFramework. Example commands:
xcodebuild archive \
-scheme DemoSDK \
OTHER_SWIFT_FLAGS="-no-verify-emitted-module-interface" \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/DemoSDK.framework-iphoneos.xcarchive' \
-UseModernBuildSystem=YES \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES,
Problem
After adding the LiveKit SPM package, the archive fails with:
** ARCHIVE FAILED **
The following build commands failed:
SwiftEmitModule normal arm64 Emitting module for LiveKit (in target 'LiveKit' from project 'LiveKit')
EmitSwiftModule normal arm64 (in target 'LiveKit' from project 'LiveKit')
Archiving project DemoSDK with scheme DemoSDK
Things I have tried:
- Cleaning DerivedData
- Checking Debug/Release build settings
- Using BUILD_LIBRARY_FOR_DISTRIBUTION=YES
- Switching Swift version between 5 and 6
Yet the archive still fails at Swift module emit. What is the proper way to include SPM packages like LiveKit into an XCFramework without causing archive failures?
lang-swift