Swift bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.
Ready to learn? Jump to code examples!
A swifty interface and app lifecycle to ease development with raylib!
- Use a swifty interface!
- Support for
@main
lifecycle - Decent examples collection with +23 code examples!
- Extensive documentation, both in your IDE and via DocC!
- You can still do C interop if needed, but consider opening a pull request!
import RaylibKit
@main struct MinimalWindow: Applet {
init() {
Window.create(800, by: 450, title: "Example - Core - Basic Window")
Application.target(fps: 60)
}
func draw() {
Renderer2D.text(center: "Congrats! You created your first window!", color: .lightGray)
}
}
First you'll need to install raylib as a system library and add this package as a dependency.
You can then start learning! Check out the examples to quickly get an idea and make sure your installation works!
Documentation is available via DocC. For Xcode users simply go to Product > Build Documentation
or press ⌃⇧⌘D
(alt-shift-command-D). For others the documentation is available in the releases as a website you can run locally.
You should start by installing raylib as a system library, see the official guide here.
The easiest way is via one of the supported package managers.
Add the following line to your Package.swift
dependencies...
.package(url: "https://github.com/Lancelotbronner/swift-raylib.git", from: "4.5.0")
...along with the following line to your target dependencies and import RaylibKit
!
.product(name: "RaylibKit", package: "RaylibKit"),
If you still need to interop, you can import raylib
and use the cheatsheet for reference.
There is a fully configured workspace for this repository, associated examples and developer tools at swift-raylib-workspace. The goal is to reduce the clone size of swift-raylib
as its used as a dependency and avoids adding too many automatically generated Xcode schemes.