# With SwiftPM, how to distribute a framework as static (vs dynamic)

**URL:** <https://forums.swift.org/t/with-swiftpm-how-to-distribute-a-framework-as-static-vs-dynamic/73388>\
**Category:** Using Swift\
**Tags:** packagemanager, static, xcframework\
**Created:** [July 23, 2024, 8:51am UTC](https://forums.swift.org/t/with-swiftpm-how-to-distribute-a-framework-as-static-vs-dynamic/73388 "2024-07-23T08:51:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mart1n](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mart1n/32/36603_2.png) [@mart1n](https://forums.swift.org/u/mart1n)\
**Post date:** [July 23, 2024, 8:51am UTC](https://forums.swift.org/t/with-swiftpm-how-to-distribute-a-framework-as-static-vs-dynamic/73388/1 "2024-07-23T08:51:23Z")

</div>

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](https://developer.apple.com/documentation/xcode/distributing-binary-frameworks-as-swift-packages). So we did our package:

```swift
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?
