A Poor Man’s Swift Godot

1 minute read

I started writing Swift plugins for Godot using the existing Objective-C plugin support without using the famed SwiftGodot library.

It was easier for me to integrate, since I already have Objective-C plugins. As a bonus, it doesn’t add much to my binary size.

I can’t share it right now since it’s basically hacks that work only for me (duct tape + bubble gum) – something something, my proof is too big to fit in the margins – but the gist is to use @objc annotations in Swift for methods you want accessible by Objective C, and have the following flags for swiftc when compiling the header: -import-objc-header {bridging_header} -emit-clang-header-path {swift_header}.

Create a bridging header so Swift can access your Objective C code, the @objc functions in Swift can be called by your Objective C code, and you can manage UI and application state in a more sane, thread-safe, compiler-friendly, Swift-y way.

Again, not perfect, but Swift is 100x more pleasant than Objective C.

Now I mainly write Objective C to pass data between Godot and Swift.

Updated: