Godot Swift Save

swift language support for the godot game engine

Project README


Swift for Godot
0.1.0

Godot Swift is a Swift Package Manager plugin that builds and packages Swift projects as Godot Native libraries.

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"
    }
}

getting started

Godot Swift uses the experimental Swift package plugins feature, which is currently only available in recent nightly Swift toolchains. Because this feature is in active development, we strongly recommend using the following Swift toolchain version to avoid compilation issues:

  • DEVELOPMENT-SNAPSHOT-2021-06-01-a

We recommend using swiftenv to manage multiple Swift toolchain installations. You can install a custom toolchain using swiftenv by passing the swiftenv install command the url of the toolchain on swift.org.

For example, to install the 2021-06-01-a snapshot on Ubuntu 20.04 x86_64, run:

swiftenv install \
https://swift.org/builds/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2021-06-01-a/swift-DEVELOPMENT-SNAPSHOT-2021-06-01-a-ubuntu20.04.tar.gz

Godot Swift builds native libraries for Godot 3.3.0.

Warning: Although Godot Swift libraries should be compatible with later Godot versions, we strongly recommend using Godot 3.3.0 to avoid unrecognized-symbol errors at runtime.

To use Godot Swift in a project, add it as a dependency in Package.swift, and add the GodotNative module and the GodotNativeScript plugin to your build target.

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    name: "example",
    products: 
    [
        .library(name: "godot-swift-example", type: .dynamic, 
            targets: 
            [
                "GodotSwiftExample"
            ])
    ],
    dependencies: 
    [
        .package(url: "https://github.com/kelvin13/godot-swift/", .branch("master"))
    ],
    targets: 
    [
        .target(name: "GodotSwiftExample", 
            dependencies: 
            [
                .product(name: "GodotNative",      package: "godot-swift")
            ],
            plugins: 
            [
                .plugin(name: "GodotNativeScript", package: "godot-swift")
            ])
    ]
)

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

Open Source Agenda is not affiliated with "Godot Swift" Project. README Source: tayloraswift/godot-swift
Stars
116
Open Issues
5
Last Commit
2 years ago

Open Source Agenda Badge

Open Source Agenda Rating