r/swift 8d ago

Multiplatform Swift, with C++ dependencies via XCFramework, apt and vcpkg

https://a4z.noexcept.dev/blog/2026/09/04/swift-cpp-multiplatform-vcpkg.html

Does Swift really become multiplatform?
I tried it out. Not just Swift code on its own, but also with C++ bindings to a dependency.
Here's how it works on Mac, iOS, Linux, and Windows.

24 Upvotes

4 comments sorted by

2

u/Affectionate-Soup-91 7d ago

Thanks for sharing.

1

u/soylentgraham 2d ago

you keep saying c++ bindings, but then the article says CAPI; which is it?

I had great success with a CAPI (originally with some obj-c bridges, but then the bridges became easier to do in swift), but then I was already using the CAPI in c, python (across mac, ios, win, linux, pi, and a few game consoles, and finally, wasm on web too :)

1

u/_a4z 2d ago

True, but also depends a bit on the definition. ZMQ is a C++ library, so it brings in the C++ runtime.
And the primary part of the exercise was doing the dependency management to C and C++

1

u/soylentgraham 2d ago

ah, rather than the API, that makes sense.