We build a closed source Framework containing a few dependencies which are imported using Cocoapods. The framework is then distributed as a pod and embedded into various internal and external projects.
I have developed a private Package (SPM) that is meant to be consumed by the Framework. It is imported to the Framework's Xcode workspace as a Swift Package Dependency (along with the other Cocoapods dependencies). The package contains resources (.xib, images, localizedStrings) which are all private - the package's public API only exposes a UIViewController that itself uses all these resources (package accesses resources through
The Framework's Xcode project also contains a target (a test iOS App) for simply importing and running the framework. Everything works perfectly. The test app is able to run the framework (
import Library) and when the framework loads the UIViewController from the Swift Package (which in turn loads all the resources) everything display without trouble.
The problem comes when I archive the library. The
.bundle from the Swift Package doesn't get copied into the resulting xcarchive. This leads to a crash happening at runtime when we run our framework inside other apps.
Fatal error: unable to find bundle named SPMPackage_Module
This crash happens because the app isn't able to find the bundle when calling
Bundle.module. This led me to find that the bundle indeed wasn't anywhere to be found in the Framework.
Our script archives the library (
xcodebuild archive ...) on both
iphoneos platforms and then packages the result as a universal framework. I would expect the package's bundle to be part of the archive but it's not.
I have found the bundle in the DerivedData folder:
There is also an alias to that file in there:
If I take that bundle and copy it into the Framework, then everything runs fine.
- Is this a bug or am I missing a step when archiving my library? (That would lead to the swift package's bundle not being copied into the resulting archive)
- Any better workaround that what is mentioned above?