I’ve been building a game in pure Swift. Here’s where it’s at.
For a while now I've been spending the little bits of spare time I can find during my nights and weekends building an action roguelike game. Think something like the gameplay loop of Hades. Room-by-room dungeon runs, procedural loot, crafting, boss fights. The twist is that the whole thing is built in native Swift using RealityKit. No Unity. No Unreal. No third-party game engine at all.
I wanted to see how far I could push Apple's frameworks into territory they weren't really designed for, and it turns out... pretty far.
What's in it
The game has auto-fire combat where your weapon targets the nearest enemy and fires automatically. The depth comes from equipment builds. Weapons drop with randomized stats and modification sockets, and you craft mods from materials you collect across runs. Die and you lose your gear, but you keep your materials and crafting recipes. Classic roguelite loop.
Right now there are 9 enemy types, each with their own AI. Rushers flank you, archers maintain distance and reposition for line of sight, healers flee and tend wounded allies, exploders rush you and detonate on death. The AI runs on behavior trees, and enemies can attack while moving, chasing, or retreating. They don't have to stop and swing.
There's an initial pass at a boss fight with multi-phase attacks (ground slams, lava pools, meteor showers), a crafting system with recipe discovery, 8 status effects that stack and interact with each other, and a poise system that prevents enemies from getting permanently stagger-locked.
What it has taken to get here
As of today the codebase consists of about 56,000 lines of Swift across 363 files including 33 custom ECS Components and 17 RealityKit Systems. There is also a custom data-driven ability system so I can add new mechanics without touching existing code. Enemies are driven from behavior trees with a standalone macOS debugger app that connects to the running game over Bonjour and shows enemy decision-making in real time.
The debugger app showing a live look at the ranged archer’s behavior tree. Since the player isn’t in range the enemy is patrolling.
The whole thing runs on iOS, iPadOS, macOS, and visionOS from the same codebase.
Fair warning: visually, everything is still running on basic primitives. Cubes, spheres, the works. I'm just starting to learn Blender for real 3D assets, so for now the visuals are... functional. But the systems underneath are where the interesting stuff is happening.
What's next
There is a mountain of work ahead to get from where things are at to a full game release. I'm going to start writing about updates to the game as well as the technical problems I've solved along the way. Things like: how do you let enemies attack while they're chasing you? What works out of the box on each platform and what took a little creativity to work around? How do you prevent stagger-locking with high-DPS auto-fire weapons? How do you handle collision deduplication when RealityKit fires events every frame while entities overlap?
If you're into Swift, RealityKit, game architecture, or just want to see what native Apple frameworks can do when you push them, follow along. I'll be posting regularly.