Note
This project is no longer maintained. I'm working on a declarative framework as an alternative.
Dvandva is a framework for creating user interfaces for GNOME and macOS with one shared code.
Dvandva’s goal is not to provide bindings for every widget on both platforms, but to make the creation of cross-platform apps easier. It’s always possible to add any widget to an app using the NativeWrapper
widget.
If you find yourself using NativeWrapper
for a widget that is available on both platforms in a similar form, consider opening an issue here.
If you are using a Linux distribution, install libadwaita-devel
or libadwaita
(or something similar, based on the package manager) as well as gtk4-devel
, gtk4
or similar.
On macOS, I recommend installing Swift Bundler.
- Open your Swift package in GNOME Builder, Xcode, or any other IDE.
- Open the
Package.swift
file. - Into the
Package
initializer, underdependencies
, paste:
.package(url: "https://github.com/david-swift/Dvandva", from: "0.1.0")
Create an executable target in the Swift package and add the following code:
import Dvandva
let app = Application("AppName", version: "0.1.0", id: "id.for.Gnome", developer: "Developer")
app.run {
let window = Window(id: "main", app: app)
window.setChild(
PaddingWrapper(
Label().setText("Hello, world!")
)
.setPadding(20)
)
window.show()
}
Now, you can modify the windows. Take a look at the sample app and the docs for help.
On macOS, I recommend using Swift Bundler for building the app. When building the app simply with swift run
, the menu bar and therefore keyboard shortcuts are not supported.
On Linux, you can simply use swift run
. In certain scenarios, setting up a Flatpak with the Swift extension may be sensible. This tutorial is very helpful.
- Libadwaita licensed under the GPL-3.0 license
- The contributors
- SwiftLint for checking whether code style conventions are violated
- The programming language Swift
- SourceDocs used for generating the docs
- AppKit and Libadwaita for the widgets