• Stars
    star
    628
  • Rank 71,541 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cross-platform declarative UI framework, inspired by SwiftUI.

GitHub

A SwiftUI-like framework for creating cross-platform apps in Swift. It uses SwiftGtk as its backend (GTK 4.10+).

This package is still quite a work-in-progress so don't expect it to be very useful or stable yet.

NOTE: SwiftCrossUI does not attempt to replicate SwiftUI's API because SwiftCrossUI is intended to be simpler than SwiftUI. However, many concepts from SwiftUI should still be transferrable.

Example

Here's a simple example app demonstrate how easy it is to get started with SwiftCrossUI:

import SwiftCrossUI

class CounterState: Observable {
    @Observed var count = 0
}

@main
struct CounterApp: App {
    let identifier = "dev.stackotter.CounterApp"
    
    let state = CounterState()
    
    let windowProperties = WindowProperties(title: "CounterApp")
    
    var body: some ViewContent {
        HStack {
            Button("-") { state.count -= 1 }
            Text("Count: \(state.count)")
            Button("+") { state.count += 1 }
        }
    }
}

To run this example, run these commands:

git clone https://github.com/stackotter/swift-cross-ui
cd swift-cross-ui
swift run CounterExample

To see all of the examples, run these commands:

swift run CounterExample
swift run RandomNumberGeneratorExample
swift run WindowPropertiesExample
swift run GreetingGeneratorExample
swift run FileViewerExample
swift run NavigationExample

Documentation

Here's the documentation site. Keep in mind that the project is still very much a work-in-progress, proper documentation and tutorials will be created once the project has matured a bit, because otherwise I have to spend too much time keeping the documentation up-to-date.

Dependencies

  1. Swift 5.5 or higher
  2. Gtk 4.10+
  3. clang (only required on Linux)

macOS: Installing Gtk 4.10+

Install Gtk 4.10+ using homebrew or the package manager of your choice.

brew install gtk4

Linux: Installing Gtk 4.10+ and clang

Install Gtk+3 and Clang using apt or the package manager of your choice. Ensure that the installed version of Gtk is Gtk 4.10+

sudo apt install libgtk-4-dev clang

Usage

Just add SwiftCrossUI as a dependency in your Package.swift. See below for an example package manifest:

import PackageDescription

let package = Package(
  name: "Example",
  dependencies: [
    .package(url: "https://github.com/stackotter/swift-cross-ui", .branch("main"))
  ],
  targets: [
    .executableTarget(
      name: "Example",
      dependencies: [
        .product(name: "SwiftCrossUI", package: "swift-cross-ui")
      ]
    )
  ]
)

More Repositories

1

delta-client

An open source Minecraft Java Edition client built for speed.
Swift
325
star
2

swift-bundler

An Xcodeproj-less tool for creating cross-platform Swift apps.
Swift
294
star
3

swift-macro-toolkit

A powerful toolkit for creating concise and expressive Swift macros
Swift
229
star
4

relativistic-renderer

Swift
21
star
5

swift-css-parser

A lightweight CSS parser for parsing and creating CSS stylesheets
Swift
13
star
6

swift-mixin

An intuitive library for hooking functions in Swift.
Swift
12
star
7

swift-lint-plugin

A SwiftPM plugin that adds a linting command
Swift
10
star
8

the-ctf-book

An interactive course accompanied by a CTF, that brings you right through from beginner to advanced in a variety of fields relevant to hacking.
Python
8
star
9

galah

A scripting language with the goal of being lightweight and embeddable in Swift applications.
Swift
8
star
10

scute

An extensible static site generation tool built with Swift.
Swift
6
star
11

delta-website

The website for Delta Client. Created with svelte.
Svelte
5
star
12

uq-maps-reborn

A new and improved (unofficial) version of UQ Maps with 360 degree imagery and superior walking/accessible navigation instructions.
HTML
5
star
13

swift-image-formats

A Swift library for working with a variety of image file formats.
Swift
4
star
14

maths-problem-gen

A maths problem generator written in Rust
Rust
4
star
15

swift-protobuf-gen

Generate protobuf message definitions from Swift structs
Swift
3
star
16

delta-core

The package that holds the code for DeltaClient. DeltaClient just provides the UI.
Swift
3
star
17

swift-cmark-gfm

A minimal wrapper around cmark-gfm
C
2
star
18

dawn-builds

A collection of scripts for building the Chromium's Dawn library. Also provides prebuilt binaries as releases.
Shell
2
star
19

ctf-replay

Allows downloading of individual ctfs and challenges from the massive `sajjadium/ctf-archives` repo.
Python
2
star
20

swiftpm-workspaces

Vend multiple SwiftPM packages from a single repository
Swift
1
star
21

homebrew-dawn

An unofficial homebrew tap for installing Dawn, a WebGPU implementation
Ruby
1
star
22

texture-viewer

A simple Minecraft block texture viewer for macOS
Swift
1
star
23

delta-plugin-template

The template for Delta Client plugins.
Shell
1
star
24

learn-hacking-resources

Resources for learning hacking; collated and created by the Digital Overdose CTF team
1
star
25

swift-libwebp

A simple Swift wrapper for libwebp.
C
1
star
26

norm-bench

An alternative to WordBench with better crossword setting!
Python
1
star
27

swift-bundler-templates

Swift Bundler's in-built package templates
Swift
1
star
28

delta-bot

The official bot for the Delta Client Discord server
Python
1
star