Proof of Concept Project: Combining Swift and C# on Windows with SwiftToCLR

Hey folks,

Over the past little while I've been exploring the idea of writing a "hybrid" C#/Swift app by using Swift's new C++ interop feature as a "bridge" between the two worlds. We'd eventually like to ship production-quality apps to users in this manner, and it was a long journey with lots of twists and struggles.

The result is a command-line tool called SwiftToCLR that automatically generates the wrapper layers needed to call into Swift from C# (via C++/CLI).

I've made an extensive write-up of this project in the form of a blog post and a GitHub repo containing everything I've built.

The blog post is a lighter discussion of the project and its journey, and you can find that here: Daniel Kennett - Proof of Concept Project: Combining Swift and C# on Windows with SwiftToCLR

The GitHub repo's README is a more technical overview of the challenges involved, as well as the current Swift C++ interop limitations that we'd need to work around (or wait to get resolved) in order to continue. That's here: GitHub - Cascable/swift-on-windows-poc: A proof-of-concept project for Swift on Windows with bindings to C#/the CLR.

Depite the current limitations, this was a really interesting project and I'm really excited about the future of Swift on Windows.

(I wasn't sure whether this should go in here, the Swift on Windows subforum, or the C++ Interop subforum - hopefully here + tags is correct.) Perhaps this is interesting to @cxx-interop-workgroup too?

27 Likes

WOWWW !!! Simply fantastic work !
Thanks for detailled explanations on the design and strategies you adopted.
The section on current limitations and some possibles workaround is goldmine too.
The future of using Swift on Windows shine.

Thanks to you and the Swift Cxx interop team !!

3 Likes

Awesome work! Thanks for sharing this!!!

1 Like

Very cool. Sorry you had to slug through such a trial to get it working, but selfishly and on behalf of the Swift community, thank you for doing so. :laughing:

Thank you in particular for the detailed write-up and published source.

1 Like

Very interesting project and a great write-up!

1 Like