I'm working on SwiftCrossUI a bit again and I'd like to try running it on Windows for myself. Swift 5.7.1 is now released and the Vcpkg port seems to have made it into a release (added in release 2022.10.19) so as far as I understand this should be possible without unreleased patches now?
I'm happy to write the guide for SwiftCrossUI if you don't have the time, as long as you can give some basic pointers on how to get Gtk compiling and installed (as a non-Windows user).
Great work that you are doing, having a cross-platform GUI library is certainly a good idea. But what I would be more interested in is getting native GUIs on Mac, Linux, and Windows. GTK+ might be a good choice for that when being on Linux. For Windows, The Browser Company is working on ādeclarative bindings for WinUI3ā, and they said they would like to open-source it, and that they would like it to be as far as possible ācompatibleā with SwiftUI, if I understood it correctly. So maybe it might be possible to some degree to use the same application code to get a native GUI on all three platforms? Just using compiler directives where the code differs / using special features of a platform? Maybe these projects should collaborate at some points?
That would definitely be possible, thanks for alerting me to that project! It is a future goal of mine to allow making native UIs with a single code base, but that is a very broad and difficult problem to solve (differing layout systems etc.). I've been sticking to using a single backend so that SwiftCrossUI code hopefully produces a predictable UI on all systems until it is more stable.
I would love to move away from Gtk because imo it's clunky, UBD (ugly-by-default) and it also doesn't support iOS. I've been looking into making an experimental custom renderer backend with WebGPU (using a work-in-progress wrapper of wgpu-native for Swift called Kinzoku). Not because it's necessarily the best solution, mostly just because I'm interested in writing a renderer with WebGPU Anyway that would be experimental and quite a while off. It probably wouldn't ever become a stable backend.
My overarching plan for getting a native look on all platforms is to
create more abstraction between the view graph and the Gtk backend (there is already pretty good separation, but it will need to be improved further to allow for the view graph to be backend agnostic)
implement an AppKit/UIKit backend (either or both) as a proof of concept that SwiftCrossUI can work with multiple backends
create a Windows-specific backend
Community-made backends will be welcomed too of course
I plan on allowing developers to choose between all available backends on a single platform. That is, they can choose to use Gtk on all desktop platforms if they want maximum consistency, or they could use Gtk on Windows and Linux but AppKit on macOS, etc.
Yes, vcpkg has accepted gtk3 and weāre able to build it on Windows now. However, static linking is not available because of a pango bug (patch submitted but not merged, Iām going to recheck its state).
For a quick reference on how to use it from SwiftPM:
Clone vcpkg at the root of a drive, eg. C:;
Run C:\vcpkg\bootstrap-vcpkg.bat to set up Vcpkg;
Run C:\vcpkg\vcpkg.exe install gtk3:x64-windows to build and install the package;
Set the environment variable though set PKG_CONFIG_PATH=C:\vcpkg\installed\x64-windows\lib\pkgconfig.
If you donāt wanna wait around, you can check out SwiftCrossUI Itās still quite experimental but weāre making pretty quick progress on adding more views and a better layout system and all that.
You might then have a look at the video in this tweet (it is missing a little bit the reference that the Visual Studio Code extension is originally made by others and that Swift on Windows is an older thing in the making, but I attribute this to the enthusiastic style of Hursh Agrawal).
You may also have a look at the tweets of Steve Kirbach.
The videos by The Browser Company are generally fun to watch, but they also seem really serious about what they are doing. A big win for the Swift community! And also for Saleem Abdulrasool, who can devote much more time for something he seems to be enthusiastic about. Congratulations!
I havenāt tried Qt with c++ interop, but I have tried it a bit before 5.9 (SwiftCrossUI is built on top of frameworks including Gtk, Qt, and WinUI).
The main reason that Iām porting SwiftUI to other platforms is that I believe itās a much more expressive way of making apps, and itād make porting macOS/iOS apps to non-Apple platforms a lot easier.
If you like Qt, thereās nothing to stop you using it!
I was just reading through this thread again and thought Iād give a quick update on this. SwiftCrossUI now has an AppKit backend and a WinUI backend, providing a native look on all three major desktop platforms. You can also now use the DefaultBackend product to get SwiftCrossUI to automatically use whichever backend is native on the platform that youāre building for. For development purposes you can override the default backend like so SCUI_DEFAULT_BACKEND="GtkBackend" which eg allows you to test out your linux ui on macOS so that you donāt need to use a virtual machine as often (this environment variable takes effect at build-time, not runtime).
The WinUI and AppKit backends still need work of course (mostly in terms of undesirable layouts) but the initial work is done.