With Xcode and frameworks it has been possible to wrap a static library, and have a framework statically link with that library. A good example would be an Objective-C wrapper for a C++ library.
I have been trying to accomplish such a thing with a Swift Package, and it seemed easy but I believe there might be a bug in SPM. Or I am doing something wrong but can't figure it out.
I pushed an example here https://github.com/quentinfasquel/MyDependencySample
- Packaging a static library along with its headers as an XCFramework is easy (using binaryTarget)
1- Using that library in a Swift Package and have it build is easy
2- Using that Swift Package in an app will not work as this Swift Package won't be able to compile.Somehow the XCFramework's headers don't seem to be found.
3- Manually dragging the
.xcframework in your final target solve the issue (sometimes) but I find it inconvenient and not ideal to have a reference to "BUILD_PRODUCT/../../Package.."
4- Adding a product to the Swift Package for the binaryTarget and add that product to the final app target fixes the problem but does something not-OK : export libMyCppLibrary.a into the app bundle's Frameworks directory... that should never happen.
5- Also, back to the Swift Package outside an app, trying to
archive it will not work and trigger the same "header not found" issue.
In need of help, or an official saying that this is a bug.