Play
Drag
0%
Talk

Reinventing SwiftUI layout system from scratch.

iOS
Andrii Zinoviev
macOS developer
iOS
Platform
Time
Date
Location

I came up with this idea while building a PDF rendering engine for my app. Laying out elements manually with frames turned out to be a nightmare - especially when dealing with text measurement and adaptive layouts. Being familiar with SwiftUI’s layout engine, I decided to implement something similar from scratch.

After many days of disassembling SwiftUI binaries, I built a working open-source version: OpenLayout (https://github.com/shivatinker/OpenLayout). The repo is a bit outdated, but I plan to update it for the talk.

It turns out the core layout logic is surprisingly simple and intuitive. With this engine, I could render PDFs with complex layouts using a SwiftUI-like DSL.

The real breakthrough came when I had to debug layout issues in other apps. Reimplementing the core layout principles and modifiers transformed my understanding - no more random .fixedSize or .frame hacks to fix tricky bugs. I’d love to share this knowledge so more developers can explore this elegant system.


We’ll cover:
       - Core logic behind SwiftUI’s layout system
       - Framework architecture: Core, DSL, Text
       - Designing key concepts like sizeThatFits and placeSubitems
       - Building leaf layouts (stretchable, fixed, text-like)
       - Creating basic containers and modifiers: padding, frame (fixed/flexible), fixedSize
       - Deep-diving into HStack/VStack logic and flexibility
       - Connecting everything and attaching a renderer/visitor
       - Writing a SwiftUI-like DSL with result builders and API tricks
       - Using random test generation to compare against SwiftUI at scale
       - Closing thoughts on integrating constraint-based and SwiftUI-like systems (e.g. UIHostingViewController)

I believe great talks come from genuine passion. I’ve always been fascinated by layout systems, and helping others discover new techniques energizes me. Also, I promise a bit of fun in this rather technical talk.