SwiftGtk
SwiftGtk provides Swift bindings for Gtk+ 3. It currently supports both macOS and Linux (with Windows support planned).
Dependencies
- Swift 5.5 or higher
- Gtk+ 3
- clang (only required on Linux)
macOS: Installing Gtk+ 3
Install Gtk+ 3 using homebrew or the package manager of your choice.
brew install gtk+3
Linux: Installing Gtk+ 3 and clang
Install Gtk+3 and Clang using apt
or the package manager of your choice.
sudo apt install libgtk-3-dev clang
Usage
Add SwiftGtk as a dependency of your project using Swift Package Manager. Below is an example package manifest that has SwiftGtk as a dependency.
import PackageDescription
let package = Package(
name: "GtkHelloWorld",
dependencies: [
.package(url: "https://github.com/stackotter/SwiftGtk", .branch("main"))
],
targets: [
.executableTarget(name: "GtkHelloWorld", dependencies: ["SwiftGtk"])
]
)
Demo
First install the required dependencies as listed above. And then run the following commands:
git clone https://github.com/stackotter/SwiftGtk
cd SwiftGtk
swift run Demo
macOS
License
All code is licensed under MIT license.