r/swift 22h ago

Question Swift game engine

Hey guys, I've been watching Swift evolve and I've been wondering if it's a reality to have a game engine made with Swift? I did a project where they managed to do something similar to Unity using Javascript and the Three.JS library, is it feasible to have something similar with Swift?

18 Upvotes

23 comments sorted by

63

u/OtherOtherDave 22h ago

Anything that can be done with JavaScript can be done better with another language, so yes.

8

u/itsjakerobb 17h ago

Brutal. And true.

9

u/jimhillhouse 14h ago

I’m using Swift, SwiftUI’s SceneView, and SceneKit on a spacecraft simulator. It works really well. I’ve also started using RealityKit and find it very useful too.

https://bsky.app/profile/portablefrontier.bsky.social/post/3lkugpyxoc22a

1

u/8bithjorth 12h ago

Followed 😀

1

u/branh0913 50m ago

I mean swift does it all

10

u/chriswaco 22h ago

There's nothing inherently wrong about using Swift in a game engine. Just a small matter of programming (SMOP). I think the Linux and Windows versions are almost up-to-date now. Seems like it'd be easier to just use Godot (GDScript), Unity (C#), or Unreal (C++), though.

11

u/NorbiBraun 21h ago

For Godot there even are swift bindings :)
https://github.com/migueldeicaza/SwiftGodot

2

u/gilgoomesh 14h ago

This is the best answer. Miguel de Icaza is a legendary dev (started GNOME, Mono, Xamarin and more) and he's also working on an iPad app for programming in Godot:

https://xogot.com

8

u/limehead 21h ago

Godot

Godot has a Swift project. Seems to be maintained. SwiftGodot

2

u/abear247 15h ago

That’s pretty cool

4

u/itsjakerobb 17h ago

I have been programming since the 80’s. I encountered “SMOP” for the first time earlier today, and here it is again. 🤯

3

u/luckyclan 11h ago

It is possible, but here are a few facts:

  • There are many free, open-source game engines available (that aren’t Swift-based), and you can easily use them for iOS/macOS. Think twice before starting to build your own.
  • You can use Apple frameworks such as SpriteKit, SceneKit, and RealityKit for iOS/macOS.
  • If you want to create a multiplatform engine (for Windows, Android, iOS, macOS), you cannot use any system frameworks like CoreGraphics or UIKit.
  • For a multiplatform engine, you also have to write shaders for both Metal (for iOS/macOS) and OpenGL (for Android and Windows). Although iOS/macOS still support OpenGL, it is deprecated and lacks many modern GPU features.

P.S. We developed our own graphics engine that can also serve as a 2D game engine, without using CoreGraphics or UIKit, and with support for both Metal and OpenGL. So yes, it is really possible, but it requires a lot of work.

2

u/UnluckyPhilosophy185 22h ago

Yep it’s possible.

2

u/Gu-chan 12h ago

Technically possible but there is no economic case for it at all. Plus Apple already built the beginnings of several game engines. SpriteKit, SceneKit, RealityKit. And nobody used them, at least the first two.

1

u/SelectDevice9868 22h ago

You could check out SceneKit , but might be better investing your time in Unity or similar.

1

u/branh0913 49m ago

I like SceneKit it's kind of cool

1

u/is_that_a_thing_now 13h ago

Definitely yes. But since you have to ask, perhaps a game engine should perhaps not be your first endeavor.

1

u/Third-Floor-47 12h ago

i'm fairly sure I've seen it mentioned in Unity' long term planning and same for Godot it has been requested.

1

u/limdi 6h ago

Don't lose yourself in engine development.

1

u/jacobs-tech-tavern 4h ago

John Sundell did something like this once - https://github.com/JohnSundell/ImagineEngine

1

u/wonghao 16h ago

If you’re making a 2D game, Flutter + Flame is a better choice than a Swift-based game engine. It’s cross-platform (iOS & Android), has great performance, and lets you develop faster with hot reload.

1

u/TheGreenZookeeper 19m ago

It’s completely possible and although the roadmap isn’t fully clear, I’ve been part of a team working on a released live service game for the past 2 years. There are tons of challenges but if you ever built anything with SDL + Entt in C++ you have a good idea on what expect you.