SwiftSDL is an open-source Swift library that provides a convenient interface for working with the C-based SDL (Simple DirectMedia Layer) library. This wrapper allows developers to leverage SDL's cross-platform multimedia and game development capabilities in Swift applications across macOS, Linux, Windows, and iOS.
The library integrates seamlessly with the Swift Package Manager (SPM), making it simple to manage dependencies and build your projects without requiring a framework file on macOS. In addition, the library includes a sample application for iOS to demonstrate how to integrate SDL within iOS apps using a bridging header.
- Swift wrapper for the SDL library (vers. 3), exposing SDL's core functionality in an easy-to-use Swift API.
- Cross-platform support for macOS, Linux, and Windows, with simplified project management using the Swift Package Manager.
- iOS support using Objective-C to Swift bridging for SDL integration.
- A sample iOS application that demonstrates how to set up and use SDL3 with this library.
Below is a basic example of how you can use SwiftSDL to initialize an SDL window in Swift:
You can add SwiftSDL as a dependency in your project by adding the following to your Package.swift
file:
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "SwiftSDLTest",
platforms: [.macOS(.v10_15)],
dependencies: [
.package(url: "https://github.com/KevinVitale/SwiftSDL.git", from: "0.2.0-alpha.4"),
],
targets: [
.executableTarget(
name: "SwiftSDLTest",
dependencies: ["SwiftSDL"],
// Optional: bundle resources!
resources: [
.process("../Resources/BMP")
],
// Required: when using SPM YOU MUST
// have libSDL3.{dylib|so|a} installed.
linkerSettings: [.unsafeFlags(
[
"-Xlinker", "-F", "-Xlinker", "/usr/local/lib",
"-Xlinker", "-rpath", "-Xlinker", "/usr/local/lib",
], .when(platforms: [.macOS])
)]
),
]
)
// TODO
Fix Me: Something like:
We welcome contributions from the community! Feel free to fork the repository, submit issues, or create pull requests. Be sure to follow the contribution guidelines and coding standards outlined in
CONTRIBUTING.md
.
SwiftSDL is open-sourced under the MIT license. See the LICENSE
file for details.
Fix Me: Something like:
For questions or further assistance, please reach out via GitHub issues or contact the maintainers directly at
email@example.com
.
With SwiftSDL, you can effortlessly bring SDL's cross-platform multimedia power into the world of Swift!