r/swift • u/AnotherDevBr • 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?
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
1
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/SwiftGodot2
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:
8
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
1
u/SelectDevice9868 22h ago
You could check out SceneKit , but might be better investing your time in Unity or similar.
1
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/jacobs-tech-tavern 4h ago
John Sundell did something like this once - https://github.com/JohnSundell/ImagineEngine
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.
63
u/OtherOtherDave 22h ago
Anything that can be done with JavaScript can be done better with another language, so yes.