# Static / dynamic library in pure swift

**URL:** <https://forums.swift.org/t/static-dynamic-library-in-pure-swift/33578>\
**Category:** Using Swift\
**Tags:** dynamic, static, framework\
**Created:** [February 8, 2020, 12:48am UTC](https://forums.swift.org/t/static-dynamic-library-in-pure-swift/33578 "2020-02-08T00:48:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [February 8, 2020, 12:48am UTC](https://forums.swift.org/t/static-dynamic-library-in-pure-swift/33578/1 "2020-02-08T00:48:03Z")

</div>

is it possible to create swift static or dynamic library or a framework without exposing the source code?

i am thinking of splitting the sources so that protocols are exposed (similar to how .h files are exposed in C / Obj-C) while the rest of the code is compiled (like .c / .m files compiled to .a or dylib or a framework). some bloat will appear as a result of those efforts (e.g. duplicating what was in the class to the protocol, etc). am i on the right track or is there a better approach?

ideally i do not want to involve Obj-C.

---

<div class="post-metadata">

**Author:** ![Braden\_Scothern](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/braden_scothern/32/1580_2.png) [@Braden\_Scothern](https://forums.swift.org/u/Braden_Scothern)\
**Post date:** [February 8, 2020, 3:35am UTC](https://forums.swift.org/t/static-dynamic-library-in-pure-swift/33578/2 "2020-02-08T03:35:06Z")

</div>

You will want to watch [this](https://developer.apple.com/videos/play/wwdc2019/416). SwiftPM is adding support for binary dependencies that are xcframework files.

If you want this on non Apple platforms as well you will have a lot more trouble. You have to provide a way to download all the artifacts and people linking have to provide flags the linking flags. I successfully did this at my previous job but no long have access to the things I did there so I can’t tell you the flags or artifacts you will need.
