A cross-platform SwiftUI-like framework built on SwiftGtk.

Overview

SwiftGtkUI

A SwiftUI-like framework for creating cross-platform apps in Swift. It uses SwiftGtk as its backend.

NOTE: SwiftGtkUI does not attempt to replicate SwiftUI's API, it is merely inspired by SwiftUI. SwiftGtkUI is intended to be simpler than SwiftUI while also overcoming some of the limitations of SwiftUI. To achieve these goals, some fundamentally different design decisions were made which make exactly replicating the API impossible.

Dependencies

  1. Swift 5.5 or higher
  2. Gtk+ 3
  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

Just add SwiftGtkUI 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/SwiftGtkUI", .branch("main"))
  ],
  targets: [
    .executableTarget(name: "Example", dependencies: ["SwiftGtkUI"])
  ]
)

Example

To run the example:

git clone https://github.com/stackotter/SwiftGtkUI
cd SwiftGtkUI
swift run Example

The buttons don't do anything yet because support for stateful UIs hasn't been implemented.

Comments
  • Basic Counter App project not working on linux

    Basic Counter App project not working on linux

    Hi, This is a really neat project and one that I'm definitely interested in contributing to.

    I tried creating a basic Counter App with the example Package.swift in the Readme.

    I got this error in my terminal when I ran swift build

    error: product 'SwiftGtk' required by 
    package 'swift-cross-ui' target 'SwiftCrossUI' not found.
    
    

    This is what my package.swift looks like

    // swift-tools-version:5.5
    // The swift-tools-version declares the minimum version of Swift required to build this package.
    
    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")
          ]),
            .testTarget(
                name: "ExampleTests",
                dependencies: ["Example"]),
        ]
    )
    

    I'm running Pop OS which is a Ubuntu fork/derivative.

    opened by ajstrand 7
  • Implement more view types

    Implement more view types

    Currently only HStack, VStack, Button and Text are supported. The following view types would also be useful to have:

    • [x] TextField
    • [x] Slider
    • [x] ForEach
    • [x] Image

    If you think of any more, reply below.

    For reference on how to implement a container view, see the VStack implementation. For how to implement a non-container view, see the Button implementation.

    feature 
    opened by stackotter 3
  • Add WindowProperties to App protocol

    Add WindowProperties to App protocol

    Allows defining window properties from your app. Currently it has the following properties:

    • title

    • defaultWidth

    • defaultHeight

    • resizable

    title is required, while the other values are optional and default to the previously hard-coded values if not set.

    opened by NinjaCheetah 2
  • Setup SwiftLint

    Setup SwiftLint

    Linting is a great way of ensuring that a repository's code is neat. Setting up SwiftLint consists of two steps:

    • [x] Create the SwiftLint configuration file and decide which rules to use
    • [x] Create a GitHub action to automatically run SwiftLint
    enhancement 
    opened by stackotter 2
  • Create GitHub action

    Create GitHub action

    A GitHub action would be useful because it allows all supported platforms to be tested for each commit, making it a lot harder to break platform support.

    The following two GitHub actions would be the most useful:

    • [ ] SwiftLint
    • [x] swift build on macOS
    • [x] swift build on Linux
    enhancement 
    opened by stackotter 2
  • Critical errors logged by Gtk when closing an app

    Critical errors logged by Gtk when closing an app

    When closing the example app, the following output can be seen in the console:

    (<unknown>:58068): GLib-GObject-WARNING **: 08:43:20.945: instance with invalid (NULL) class pointer
    
    (<unknown>:58068): GLib-GObject-CRITICAL **: 08:43:20.945: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (<unknown>:58068): GLib-GObject-WARNING **: 08:43:20.945: instance with invalid (NULL) class pointer
    
    (<unknown>:58068): GLib-GObject-CRITICAL **: 08:43:20.945: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (<unknown>:58068): GLib-GObject-WARNING **: 08:43:20.945: instance with invalid (NULL) class pointer
    
    (<unknown>:58068): GLib-GObject-CRITICAL **: 08:43:20.945: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (<unknown>:58068): GLib-GObject-WARNING **: 08:43:20.945: instance with invalid (NULL) class pointer
    
    (<unknown>:58068): GLib-GObject-CRITICAL **: 08:43:20.945: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (<unknown>:58068): GLib-GObject-WARNING **: 08:43:20.945: instance with invalid (NULL) class pointer
    
    (<unknown>:58068): GLib-GObject-CRITICAL **: 08:43:20.945: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    opened by stackotter 1
  • Add basic

    Add basic "Getting Started" documentation

    Here's some basic documentation for getting started, basically all pulled from the README. I mainly thought this would be helpful because it means you can find all of the info you need to start working on the documentation site. Definitely can reword anything that needs to be reworded.

    opened by NinjaCheetah 0
  • ci: Split workflow into two files to show statuses for both platforms

    ci: Split workflow into two files to show statuses for both platforms

    I split swift.yml into swift-macos.yml and swift-linux.yml so that you can have a badge for each in the README to show if a specific platform is failing. The images currently don't exist and are just question marks but that will be fixed once the workflows are there.

    opened by NinjaCheetah 0
  • Make certain view modifiers independent of order

    Make certain view modifiers independent of order

    Currently doing padding before frame produces different behaviour than padding after frame when the frame height is set such that the content can scroll (the padding is either inside or outside of the scrolling area). This is clearly not the intended behaviour and will have to be solved eventually.

    bug 
    opened by stackotter 0
  • Create Picker view

    Create Picker view

    SwiftUI has a Picker view that allows a user to select an option from a list, which is implemented by the Menu widget in Gtk. It'd be nice for SwiftCrossUI to have a dropdown menu type too (called Picker for consistency with SwiftUI).

    feature 
    opened by stackotter 0
  • Windows support

    Windows support

    Theoretically, SwiftCrossUI should work on Windows, but I haven't managed to install Gtk on Windows in a way that Swift can use yet. If you use Swift on Windows, you'll probably have more luck than I did! Feel free to try and get it running.

    If you do manage to get it working, please let us now how, so that we can setup a GitHub action for Windows builds. And if an code changes are required to get it running, just make a PR.

    help wanted 
    opened by stackotter 0
  • Don't update a widget unless its state has changed

    Don't update a widget unless its state has changed

    For example, currently buttons have their text updated every time the state of their parent view changes, which is completely unnecessary given that most of the time their label is static.

    This could be achieved by adding extra checks to the update function for each view type (currently only text and button implement this).

    enhancement 
    opened by stackotter 0
  • Support multiple windows

    Support multiple windows

    SwiftUI approaches this by having the body of App be of type some Scene where a scene can define windows using a result builder.

    The way I plan on approaching this is making App.body be of type some AppContent and having a Window struct that AppContentBuilder accepts. Then _App can setup the windows accordingly in run.

    feature 
    opened by stackotter 0
Owner
Creator of Delta Client. Loves Swift and Rust.
null
Completed Project for Cross Platform Image Filter SwiftUI macOS & iOS App

Completed Project for Cross Platform Image Filter SwiftUI macOS & iOS App Follow the tutorial at alfianlosari.com Features Filter image using predefin

Alfian Losari 73 Dec 19, 2022
E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy.

Touchdown-SwiftUI E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy. Main components and concepts used: @EnvironmentOb

Jorge Martinez 5 Aug 18, 2022
Basic cross Linux/Darwin/Win(?) Posix aliases for Swift

Basic cross Linux/Darwin/Win(?) Posix aliases for Swift

The Noze Consortium 2 Nov 9, 2021
RippleQueries is an iOS application built as assessment task at Ripple Egypt. Built Using MVVM (Model-View-ViewModel) and Clean Architecture concepts

RippleRepositories RippleRepositories is an iOS application built as an assessment task at Ripple Egypt. Built Using RxSwift & MVVM (Model-View-ViewMo

Muhammad Ewaily 3 Sep 16, 2021
Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users . Providing Users availability to upload posts and images add caption allowing other users to comment , with Find section to explore new people , new stories , User Profile section to allow the user to take control of his account .

Devang Papinwar 2 Jul 11, 2022
Basic Todo list application built using the new SwiftUI framework and Core Data

Dub Dub Do - A sample TODO List Application in SwiftUI Updated for Xcode 11.5 This is a basic app that lets you create a list of todos, mark them as i

Stephen McMillan 67 Sep 28, 2022
Sample iOS project built by SwiftUI + Flux and Combine framework using GitHub API

SwiftUI-Flux Flux enables us to have unidirectional data flow and make it testable. It's used to be implemented using RxSwift or ReactiveSwift in the

Yusuke Kita 87 Nov 25, 2022
Sample iOS project built by SwiftUI + MVVM and Combine framework using GitHub API

SwiftUI-MVVM One of the biggest idea for having MVVM is that most of data flow can be testable. Data binding in view layer by SwiftUI is awesome. Howe

Yusuke Kita 592 Jan 2, 2023
A platform to showcase your side projects/apps

A platform to discuss/showcase your side projects What is this? Inspired by this twitter thread Indie Apps Showcases is a platform for indie app devel

An Tran 25 Dec 27, 2022
iOS On-Device Game Cheat Creation/Sharing Platform and Software

CheatManager CheatManager is a mobile platform, used for installation/distribution/creation of mobile game cheats/hacks. This platform is completely d

Project Manticore 49 Jan 2, 2023
EU Digital COVID Certificate Kit for the Apple Platform  (unofficial)

EU Digital COVID Certificate Kit A Swift Package to decode, verify and validate EU Digital COVID Certificates for iOS, tvOS, watchOS and macOS Disclai

Sven Tiigi 32 Oct 4, 2022
Moit: a single delivery platform for college students living in dormitories

Moit: a single delivery platform for college students living in dormitories

LeeProgrammer 0 Nov 9, 2021
Open-source platform that raises awareness of the injustice and often forgotten names of racial inequality.

Welcome to the Say Their Names project. Our aim is to build an open-source platform that raises awareness of the injustice and often forgotten names of racial inequality at the hands of law enforcement. We strive to identify and amplify verified organizations to ensure donations are reaching those who can make the most impact with it.

Say Their Names 249 Nov 10, 2022
Event management iOS app for organizers using Open Event Platform

Open Event Organizer iOS App Event management app for organizers using Open Event Platform Roadmap Make the app functionality and UI/UX similar to the

FOSSASIA 1.5k Dec 29, 2022
Booky heavily-commented demo app built to explore Apple's new 'App Intents' framework introduced in iOS 16

Booky Demo App ℹ️ ABOUT Booky is a work-in-progress, heavily-commented demo app built to explore Apple's new 'App Intents' framework introduced in iOS

Alex Hay 77 Jan 4, 2023
SwiftUI MovieDB prototype app built with Xcode 11 Beta & macOS 10.15 Catalina

SwiftUI MovieDB iOS 13 App SwiftUI MovieDB prototype app built with Xcode 11 Beta & macOS 10.15 Catalina Requirements macOS 10.15 Catalina Xcode 11 Be

Alfian Losari 297 Dec 17, 2022
iOS app that detects LaTeX symbols from drawings. Built using PencilKit, SwiftUI, Combine and CoreML for iOS 14 and macOS 11.

DeTeXt Finding the symbol you want to use in LaTeX can be hard since you can't memorize all the possible commands and packages for every symbol you mi

Venkat 73 Dec 8, 2022
🎓📊 Grade Calculator for iOS built with SwiftUI

GradeCalc - GPA Calculator Download at the App Store Product Hunt Support If you want to support the development of this app, feel free to sponsor me

Marlon Lückert 38 Dec 15, 2022
Open source game built in SwiftUI and the Composable Architecture.

isowords This repo contains the full source code for isowords, an iOS word search game played on a vanishing cube. Connect touching letters to form wo

Point-Free 2.1k Jan 1, 2023