|
||
---|---|---|
.github | ||
Icons | ||
Sources | ||
.gitignore | ||
.spi.yml | ||
.swiftlint.yml | ||
io.github.AparokshaUI.Demo.json | ||
LICENSE.md | ||
Package.swift | ||
README.md |
Adwaita for Swift
Adwaita is a framework for creating user interfaces for GNOME with an API similar to SwiftUI.
The following code:
struct Counter: View {
@State private var count = 0
var view: Body {
HStack {
Button(icon: .default(icon: .goPrevious)) {
count -= 1
}
Text("\(count)")
.title1()
.frame(minWidth: 100)
Button(icon: .default(icon: .goNext)) {
count += 1
}
}
}
}
Describes a simple counter view:
More examples are available in the demo app.
Table of Contents
Goals
Adwaita’s main goal is to provide an easy-to-use interface for creating GNOME apps. The backend should stay as simple as possible, while not limiting the possibilities there are with Libadwaita and GTK.
If you want to use Adwaita in a project, but there are widgets missing, open an issue.
Find more information about the project's motivation in this blog post.
Installation
Dependencies
Flatpak
It is recommended to develop apps inside of a Flatpak. That way, you don't have to install Swift or any of the dependencies on your system, and you always have access to the latest versions. Take a look at the template repository. This works on Linux only.
Directly on System
You can also run your apps directly on the system.
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, follow these steps:
- Install Homebrew.
- Install Libadwaita (and thereby GTK 4):
brew install libadwaita
Swift Package
- 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://git.aparoksha.dev/aparoksha/adwaita-swift", from: "0.1.0")
Usage
I recommend using the template repository as a starting point.
Follow the interactive tutorial or read the docs in order to get to know Adwaita for Swift.
Thanks
Dependencies
- XMLCoder licensed under the MIT License
- Levenshtein Transformations licensed under the MIT License
- Meta licensed under the MIT License
- SQLite for Meta licensed under the MIT License
Other Thanks
- The auto-generation of widgets is based on Swift Cross UI
- SwiftLint for checking whether code style conventions are violated
- The programming language Swift