Here, we are using several libraries provided by a partner.
Our partner provides those libraries as .xcframework files and ask us to integrate them as static libraries. As explained in their documentation:
Put them into the “Frameworks, Libraries, and Embedded Content” section in your project APP target setting. Select “Do Not Embed” for all frameworks.
As far I understand static vs dynamic libraries, this means that the framework code will be directly copied in the app executable.
In other terms, if I selected "Embed" instead of "Do Not Embed", the whole framework will be inside the .app, under MyApp.ipa/Payload/MyApp.app/Framework/
folder: the framework will then be dynamic.
Am I correct ?
Now, we just implemented a swift package that wraps the partner's SDK, adds some functionality, and simplify integration. The recommended way the use a framework in a swift package is to use a binary target. So we did our package:
import PackageDescription
let package = Package(
name: "WrapperPackage",
platforms: [.macOS(.v10_15), .iOS(.v13)],
products: [
.library(name: "WrapperPackage", targets: ["WrapperPackage"]),
],
dependencies: [
],
targets: [
.target(
name: "WrapperPackage",
dependencies: ["MyDependency"],
path: "Sources",
resources: [.process("Media")]
),
.binaryTarget(name: "MyDependency", path: "MyDependency/MyDependency.xcframework")
]
)
This works well, the app builds perfectly and the MyDependency
functionnalities can be used through the WrapperPackage
.
But how is packaged MyDependency
? After packaging my app, I dived in MyApp.ipa/Payload/MyApp.app/Framework/
and found MyDependency.xcframework
, like a dynamic framework.
So my guess is binaryTarget
makes Xcode link framework as dynamic libraries. At least by default, but I did not find any way to configure a static integration.
Is there anything I misunderstood, and is it possible to package a framework as a static library using SPM binary targets?