© 2023-2024, 2026 by Zack Smith. All rights reserved.
Overview
This is a project to get Swift working with the Qt 6 GUI library to allow the construction of conventional (non-declarative) GUIs.
The task of creating an open-source, declarative GUI builder, like QML (introduced in 2009) or SwiftUI (introduced in 2019), also seems feasible but is a task for later.
SwiftQt
, as I've called it, has the purpose of helping me create
personal apps on Linux with Qt and using Swift instead of C++ or Python,
which may be beneficial in some ways.
Is getting Swift to work with Qt easy? It consists largely of connecting things so that Swift talks to C, which then talks to C++, and then in the opposite direction, for each of the classes and methods that would be useful.
Equivalent objects must exist on both the C++ and Swift side, so some book-keeping is required.
Currently SwiftQt works with Qt 6 and Swift 6.2.4.
Screenshots
A GUI built using manual layout i.e. frame-setting.
A GUI built using box layouts (horizontal and vertical).
A GUI built using a grid layout.
Download
This source code should be considered alpha.
Sample apps:
Swift Compiler
Some Linux distro don't provide the Swift compiler, even though the Swift compiler has been buildable and running on 64-bit Linux and Windows for years.
You can download the official build from Swift.org.
How to compile the Swift compiler and its libraries
If you want, you can compile the compiler yourself.
This is straightforward but with a caveat: some of its basic libraries are coded in Swift and require that a Swift compiler is already installed. In other words, the swiftc that is being built cannot be used to compile those.
#!/bin/bash
mkdir swift-source
cd swift-source
git clone https://github.com/apple/swift.git
pushd swift
git checkout swift-6.2.4-RELEASE
popd
./swift/utils/update-checkout --clone \
--tag swift-6.2.4-RELEASE
time nice swift/utils/build-script -j2 \
--preset=buildbot_linux,no_test \
install_destdir=$HOME/swift-install \
installable_package=$HOME/swift.tgz


