Using C++ GUI frameworks with Swift 5.9 for cross-platform desktop apps

Hello everyone,

is the new native C++ interoperability able to allow the usage of any C++ GUI frameworks, for example WxWidgets or Qt? would it be too difficult to create a Clang module map for importing that kind of huge libraries ?


Hi @acaland,
It should be possible to use Qt with C++ interop. As you noted, one would have to modularize Qt headers for that. As a starting point, you could try adding a module.modulemap file that declares a single module with all of the Qt headers that you need.
Let me know if that works, or if you run into any trouble!


For related topics also see A cross-platform UI for Swift, especially A cross-platform UI for Swift - #29 by sspringer.

1 Like

although it's said to be possible to import c++ class directly from swift 5.9, it's not guaranteed to import every class you want.

There are limitations, especially for reference type of class (contrary to value type of class/struct). I'm afraid some code needs to be modified inside wxWidgets of Qt, for example, to add swift_attr to make it exported as reference type.