Automerge for Swift

I’ve been interested in the idea of CRDTs, and the use cases they enable, for a number of years. The core ideas are pretty straight forward to understand and implement, but when you start applying them into something like collaborative text editing, or more efficient size encoding, there’s a lot of additional complexity. There are existing, popular CRDT libraries (Yjs, Automerge, and others) that have worked out algorithms and at least some of the performance tradeoffs for these more complex scenarios. So while I have the swift-native library basics of CRDTs available as a swift package, I’ve been interested in seeing those more popular libraries become equally available on macOS and iOS platforms.

Over the summer, I started working with the Automerge team to bring its Rust-language core to Swift. While it’s evolving, and hasn’t hit what I’d consider a 1.0 milestone, the functionality is sufficiently complete to use effectively in iOS or macOS apps to enable interactive collaboration, or local-first documents with seamless offline sync. So today I introduced Automerge on the Swift Forums, highlighting the latest 0.5.2 release of Automerge-swift. Along with this release, and its API documentation, I’ve also published an open-source, cross-platform (macOS and iOS) document-based SwiftUI app that showcases using Automerge: MeetingNotes.

MeetingNotes has its own app-level documentation providing a walk-through of how it uses Automerge alongside SwiftUI to create iOS and macOS apps that can interactively collaborate with editing.

There’s still quite a bit of future development planned for this project, improvements in the core library as well as more effort to make seamless synchronization between various languages and platforms easier to implement. While everything is open-source, If you’re interested in more commercial-style support of this library for you apps, the research lab Ink and Switch can help provide some of that support, and funding further development of Automerge and related projects with that support. (Full disclosure: some of this summer’s work on the Automerge-swift library was funded by Ink and Switch)

Published by heckj

Developer, author, and life-long student. Writes online at https://rhonabwy.com/.