Skip to content

helbertgs/OpenSwiftUI

Repository files navigation

OpenSwiftUI

CI Codacy Badge Swift Platforms OpenGL License

A faithful, cross-platform open-source reimplementation of Apple’s SwiftUI — built without any Apple frameworks.


Overview

OpenSwiftUI is an open-source Swift framework that faithfully mirrors the API and behavior of Apple’s SwiftUI, designed from the ground up to run on any platform. Because it deliberately avoids all Apple-specific frameworks, it can target Windows, Linux, and macOS using a single, unified codebase.

The framework provides views, controls, and layout structures for declaring your app’s user interface, along with event handlers, data flow tools, and modifiers — all following the SwiftUI programming model you already know.


Why OpenGL?

OpenSwiftUI uses OpenGL 3.3+ as its sole rendering backend. OpenGL has broad, stable support across all major operating systems (Windows, Linux, macOS), making it the ideal foundation for a truly cross-platform renderer. A single rendering engine means consistent visual output everywhere, with no platform-specific rendering paths to maintain.


Dependencies

OpenSwiftUI is built on a family of cross-platform Swift libraries, each wrapping a well-established C/C++ library while exposing an idiomatic Swift API:

Library Based on Purpose
OpenGLAD GLAD 2 (C++) Loads OpenGL 3.3+ function pointers — primary rendering backend
OpenGLFW GLFW 3 (C++) Window creation and OpenGL context management
OpenSTB stb (C++) Image loading, writing, and resizing
OpenFreeType FreeType + HarfBuzz (C++) Font loading, shaping, and rendering via OpenGL
OpenSpatial Apple’s Spatial framework 3D spatial math and geometry — replaces CoreGraphics and simd

All of these libraries were created by @helbertgs.


Requirements

Requirement Minimum Version
Swift 6.0
OpenGL 3.3+
Windows Latest
Ubuntu Latest
macOS 15.0

Installation

Add OpenSwiftUI to your Package.swift:

dependencies: [
    .package(url: "https://github.com/helbertgs/OpenSwiftUI", branch: "main"),
]

Then add "OpenSwiftUI" to your target’s dependencies.


Usage

OpenSwiftUI mirrors Apple’s SwiftUI API. If you have experience with SwiftUI, you’ll feel right at home:

import OpenSwiftUI

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Hello, World!")
        }
    }
}

Contributing

Contributions are welcome! Anyone can contribute — just follow the Code of Conduct and, if you are submitting code or using an automated coding agent, read AGENTS.md for repository-specific workflow, scope, and validation guidance before opening a pull request.


License

OpenSwiftUI is released under the MIT License. See LICENSE for details.

About

Open-source framework based on Apple's SwiftUI.

Topics

Resources

License

Code of conduct

Stars

79 stars

Watchers

5 watching

Forks

Contributors

Languages