How helbertgs/openswiftui works
Project Type and Purpose
• OpenSwiftUI is an open-source Swift Package that re-implements Apple’s SwiftUI framework for multiple platforms (macOS/AppKit, Windows, Linux via OpenGL/OpenUIKit).
• It’s a developer library (not a client/server or full-stack app) whose primary goal is to let you declare UIs, state, and event handling in a declarative, cross-platform way.
High‐Level Components
• Package Manager & CI
• Package.swift – defines the SwiftPM package and module dependencies
• .github/workflows – CI pipelines for Windows and Ubuntu builds/tests
• Core Framework (module: OpenSwiftUI)
• Domain-layer feature modules
– Accessibility
– Animations
– App Structure (App, Scenes, Windows, Documents, Widgets)
– Data and Storage (environment values, model data, persistent storage, preferences)
– Event Handling (gestures, input events, system events)
– View Layout & View Tree (layout engine, custom layouts, graph, tree)
• Integration & Platform Abstraction
– Framework Integration (AppKit delegators, etc.)
– Platforms (OpenGL host controllers, platform entrypoints)
• Sample Application
• Sources/OpenSwiftUISample/MyApp.swift – example app that imports and exercises OpenSwiftUI
Interactions and Dependencies
• Sample App → depends on Core Framework API (imports OpenSwiftUI)
• Feature Modules → depend on Core View Tree & Layout sub-modules
• Feature Modules → use Data & Storage for state propagation and environment values
• Feature Modules → use Event Handling for gestures and system input
• Core Framework → calls into Framework Integration and Platforms layers for OS-specific rendering and event delivery
Architectural Patterns and Principles
• Layered Modular Architecture: clear separation between
1. API (Views, Modifiers, Accessibility, Animations)
2. Core Engine (View Tree, Layout, Data Flow)
3. Integration Layer (bridges to AppKit/OpenGL/OpenUIKit)
• Feature-based organization: each major SwiftUI concept is its own directory/module
• Declarative, functional style: uses value types, protocol conformance (View, Animatable, etc.) and property wrappers
What
• Sample App
• OpenSwiftUI Core Modules (grouped by domain)
• Core Engine (View Tree & Layout)
• Framework Integration & Platform Abstraction
• SwiftPM & CI
• "imports"/"depends on" from Sample to Core Modules
• internal dependencies: Feature Modules → Core Engine; Feature Modules → Event Handling/Data Storage
• Core Framework → Platform layer → OS APIs (AppKit/OpenGL)
• Blue: public API modules (Views, App Structure, Accessibility, etc.)
• Green: core engine modules (View Tree, Layout, Data Flow)
• Orange: integration layers (Framework Integration, Platforms)
• Grey: build/CI (Package.swift, workflows)
• Labels for
• Each module’s responsibility
• Data flows (e.g., “ViewBuilder → Layout Engine → Render via OpenGL”)
• Extension points (“Custom Layouts”, “Custom Views”)
– Public API Modules (Accessibility, Animations, App Structure, Views, Event Handling, Data & Storage)
– Core Engine (View Tree, Layout)
d. At the bottom, show “OS Frameworks” (AppKit on macOS; OpenGL/OpenUIKit on Windows/Linux)
f. Connect:
– Sample App → Public API Modules
– Public API Modules → Core Engine
– Core → Integration Layer → OS Frameworks