Open PetaSoft opened 2 years ago
We aim to support multiple programming language in the future. That said, Swift is not a priority for us considering that Swift already has a natural UI framework and that Swift is not really popular on Linux and Windows. But if someone were to contribute Swift bindings, we'd happily assist them.
We aim to support multiple programming language in the future. That said, Swift is not a priority for us considering that Swift already has a natural UI framework and that Swift is not really popular on Linux and Windows. But if someone were to contribute Swift bindings, we'd happily assist them.
@ogoffart Is there a guide how to develop bindings for other programming languages?
We don't have such a guide.
There is two things to do:
For example, for C++, the wrapper is in https://github.com/slint-ui/slint/tree/master/api/cpp , and the code generator in https://github.com/slint-ui/slint/blob/master/internal/compiler/generator/cpp.rs
The best would be, I guess, to look at that and try to do something similar for swift.
If you are interested, I'd be happy to answer any questions you have, here or by chat or so.
I've spent a few weeks taking a crack at it. I'm no longer interested in pursuing this, but if someone else wants to this could be a good starting point.
Here's my result: https://github.com/illucid-matthew/slint-swift-bindings
The main things I accomplished are:
cbindgen
API into SwiftSlintApp
start()
method to initialize your UIstart()
is finishedExample:
import SlintUI
@main
struct ExampleApp: SlintApp {
static func start() {
print("⏰ Setting up a timer to fire in three seconds…")
let timer = SlintTimer()
timer.willRun(after: 3000) {
print("⏰ Timer fired!")
}
}
}
I also converted timer
and callback
, but the latter runs into a strange bug that that I'm not inclined to track down.
Beyond that, there are a few unfinished core library types, and a minor attempt to create bindings for the interpreter API.
Great that you managed to get that far with Swift bindings - thanks for sharing!
A Swift compiler exists not only for the Apple ecosystem but also for Windows and Linux but SwiftUI can only be used for Apple devices. Furthermore, Qt is a cross plattform framework, but only supports C++ and Python. Maybe, Slint can fill a gap, and become a cross plattform framework for Swift. Furthermore, I am not aware of any UI framework that supports Swift on Windows.