A comprehensive multi-platform GUI framework for Swift, supporting Windows, macOS, iOS, Linux, and Android.
- Cross-platform: Unified API across Windows, macOS, iOS, Linux, and Android
- Native performance: Direct platform API integration (WinSDK, AppKit, UIKit, GTK, Android SDK)
- Swift-friendly: Modern Swift interfaces with type safety and memory management
- RAII design: Automatic resource cleanup using Swift's
deferand ARC - Comprehensive: Windows, graphics, controls, input, dialogs, and system utilities
- Extensible: Platform abstraction layer allows easy addition of new platforms
| Feature | Windows | macOS | iOS/iPadOS | Linux | Android |
|---|---|---|---|---|---|
| Windows | β Full | β AppKit | β UIKit | π§ GTK | π§ JNI |
| Graphics | β GDI+ | β Core Graphics | β Core Graphics | π§ Cairo | π§ Canvas |
| Controls | β Win32 | β AppKit | β UIKit | π§ GTK | π§ Views |
| Input | β Win32 | β NSEvent | β UIEvent | π§ GDK | π§ MotionEvent |
| Dialogs | β Win32 | β NSAlert | β UIAlert | π§ GTK | π§ AlertDialog |
| System | β Win32 | β NSProcessInfo | β UIDevice | π§ POSIX | π§ System |
| Timers | β Win32 | π§ Foundation | π§ Foundation | π§ GLib | π§ Handler |
| Build | β MSVC | β Xcode | β Xcode | β GCC/Clang | π§ NDK |
β = Fully implemented | π§ = Stub implementation ready for enhancement
Gama uses a platform abstraction layer:
βββββββββββββββββββ
β Public API β β Window, WindowProtocol, WindowFactory
β (Unified) β
βββββββββββββββββββ€
β Platform Layer β β WindowsWindow, AppleWindow, LinuxWindow, AndroidWindow
β (Platform-specific)|
βββββββββββββββββββ€
β Core Types β β Point, Size, Rectangle, Color (cross-platform)
β (Shared) β
βββββββββββββββββββ
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/yourorg/gama", from: "1.0.0")
]import Gama
// Works on all platforms!
let window = try Window(
title: "My App",
size: Size(width: 800, height: 600)
)
window.show()import Gama
// Platform detection
if isWindows {
// Windows-specific code
} else if isApple {
// macOS/iOS code
} else if isLinux {
// Linux code
}
// Safe platform checks
try ensurePlatformSupport(for: "graphics", supported: hasGraphicsSupport)class MyDelegate: WindowDelegate {
func windowWillClose(_ window: WindowProtocol) -> Bool {
// Return false to prevent closing
return false
}
func windowDidResize(_ window: WindowProtocol, size: Size) {
print("Window resized to: \(size.width) x \(size.height)")
}
}
let window = try Window(title: "Events Demo")
window.setDelegate(MyDelegate())// Cross-platform graphics (when implemented)
let graphics = try AppleGraphics(width: 800, height: 600)
graphics.setFillColor(.blue)
graphics.fillRectangle(Rectangle(left: 0, top: 0, right: 400, height: 300))// Platform-specific controls
#if os(macOS)
let button = AppleButton(title: "Click Me")
button.setAction(self, action: #selector(buttonClicked))
#endif# Windows
swift build
# macOS/iOS
swift build -Xswiftc "-target" -Xswiftc "x86_64-apple-macos12"
# Linux
swift buildswift testSee Examples/ directory for platform-specific demos:
MultiPlatformDemo- Basic window and event demonstration
- Platform Implementation: Add support for new platforms by implementing the platform protocols
- Feature Enhancement: Extend existing platform implementations
- Testing: Add cross-platform tests
- Documentation: Update platform support matrix and guides
- Create
Platform/NewPlatform/directory - Implement
WindowProtocolwithNewPlatformWindow - Add platform detection in
Core/Platform.swift - Update
WindowFactoryto instantiate your implementation - Add to build system and documentation
See LICENSE.md for details.
- Windows implementation based on WinSDK
- Apple implementation uses AppKit/UIKit and Core Graphics
- Linux implementation designed for GTK4 and Cairo
- Android implementation designed for JNI bridge