SwiftGodot is great but it needs a lot of boilerplate to get started, especially if you're building cross-platform. This repo sets up all of that boilerplate to let you jump right in.
Setup:
- Copy all of these files directly into your Godot project directory.
- Check the version of SwiftGodot in
Driver/Package.swift
and update it if desired. - If on Windows, see additional setup instructions below.
Development cycle:
- Open
Driver
in your Swift editor of choice (usually Xcode or VS Code) - Add any newly defined Godot-visible types to
Driver.swift
- Build using Swift package manager (command line; building in Xcode puts the built libraries in the wrong directory).
For Windows, remember to use
subst
before building. - In Godot, Project > Reload Current Project (sometimes not needed e.g., when editing the implementation of a function)
- Check the Output tab in Godot for extension errors. If you see any scary symbol errors, try reloading the project or changing the SwiftGodot version.
Setting up for development on Windows is a special kind of hell.
-
Set up for Swift development, including Developer Mode so that the build can create symlinks.
-
Shorten the build path for the
Driver
package as much as possible usingsubst
to create a virtual drive:subst S: C:\Users\Whatever\Foobar\GodotProject\Driver
Strangely, setting the registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
valueLongPathsEnabled
to1
does not help. You must actually shorten the path for the build to work. -
Build only from the new virtual drive
S: swift build
If you previously tried to build without
subst
you need to completely delete all temporary build files since some contain the unshortened path and Swift won't overwrite them. -
Copy all Swift
*.dll
s to the same directory asSwiftGodot.dll
(repeat for debug/release if needed):copy "C:\Program Files\Swift\runtime-development\usr\bin\*.dll" S:\.build\debug\
Track further Windows build issues here.