Technology
Dactyl developers detail technical architecture of cross-platform SwiftUI renderer
The platform utilizes a WebAssembly port of the iOS simulator, dynamic Swift linking, and a Jetpack Compose host to run SwiftUI apps on Android and the web.
The short version
- Dactyl has detailed how its platform compiles and runs Apple's SwiftUI framework on both web browsers and Android devices.
- The system uses WebAssembly to run a reconstructed SwiftUI engine in the browser, bypassing the need for remote Mac hardware to preview iOS apps.
- On Android, the engine compiles natively and interfaces with a Jetpack Compose host, rendering native Material UI components using the same layout coordinates.
Key facts
- Dactyl's preview engine is a reimplementation of SwiftUI and several Apple frameworks, such as ARKit, SpriteKit, and MapKit, written in Swift.[Hacker News]
- For web previews, the engine compiles to WebAssembly and outputs a binary draw-command stream that is painted onto a Canvas2D by a JavaScript host.[Hacker News]
- To optimize loading times, Dactyl splits the build so the browser caches the 100 MB engine and standard library once, dynamically linking the much smaller application module at runtime.[Hacker News]
- On Android, the engine compiles natively using the Swift Android SDK, allowing a Jetpack Compose host to mount native Material widgets over a Java Native Interface (JNI) connection.[Hacker News]
- The platform's developers automate engine updates by comparing its visual output frame-by-frame against a booted iOS simulator and utilizing visual large language models to resolve discrepancies.[Hacker News]
Sources
- How Dactyl WorksHacker News