Swift language support for the Godot game engine

Swift for Godot is here!

https://github.com/kelvin13/godot-swift

Godot Swift provides bindings and a package plugin-powered build system for creating Godot native libraries from Swift frameworks. Godot Swift exposes GDScript APIs in terms of protocols and generics, allowing for seamless Swift-to-Godot interoperability.

Here’s a minimal 35-line example of a Godot Swift nativescript:

final 
class MySwiftClass:Godot.NativeScript
{
    var foo:Int = 5
    
    init(delegate _:Godot.Unmanaged.Spatial)
    {
    }
    func bar(delegate _:Godot.Unmanaged.Spatial, x:Int) -> Int 
    {
        self.foo * x
    }
    
    @Interface 
    static var interface:Interface 
    {
        Interface.properties 
        {
            \.foo <- "foo"
        }
        Interface.methods 
        {
            bar(delegate:x:) <- "bar"
        }
    }
}
extension Godot.Library 
{
    @Interface 
    static var interface:Interface 
    {
        MySwiftClass.self <- "MyExportedSwiftClass"
    }
}

tutorials and example programs

  1. basic usage (sources)
  2. advanced methods (sources)
  3. advanced properties (sources)
  4. signals (sources)
  5. life cycle management (sources)
  6. using custom types (sources)

api reference

math library reference

How you can help!

Godot Swift comes with a resource installation script that automates creating and installing .gdnlib and .gdns resource files for its build products. While Godot Swift itself is written is pure Swift, and should work on all platforms, the resource installation script currently only works on Linux. You can help port it to Windows and MacOS! (This should only require updating a few file extension patterns.)

Beyond that, Godot Swift could always use testers and tutorial writers. Feel free to open a Github issue for any questions or concerns.

Have fun!

14 Likes

This is a dream come true!

2 Likes

This is something beyond awesome. I'll have a deeper look later

1 Like
Terms of Service

Privacy Policy

Cookie Policy