GithubHelp home page GithubHelp logo

oxcug / godot-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tayloraswift/godot-swift

0.0 0.0 0.0 185.12 MB

swift language support for the godot game engine

Shell 0.33% Python 0.84% C 36.42% Swift 62.41%

godot-swift's Introduction


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")
            ])
    ]
)
  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)

godot-swift's People

Contributors

tayloraswift avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.