One Codebase, Three Platforms: X's Experience with Kotlin Multiplatform
Article Summary
X (Twitter) rebuilt their encrypted DMs for millions of users with a team of just 5 Android engineers. Their secret? Kotlin Multiplatform.
Engineers from X share their real-world experience adopting KMP to rebuild direct messages as an end-to-end encrypted feature across Android, iOS, and Web. They moved from Circuit to Decompose while keeping native UI on each platform.
Key Takeaways
- Shared encryption logic, database layer, and business logic across three platforms
- Unified logging and SQLite database made debugging consistent across platforms
- Switched from Circuit to Decompose to share business logic beyond Android
- Web required custom SQLite driver to persist encrypted messages across tabs
- Swift and JavaScript interop still has rough edges for small teams
KMP enabled a tiny team to ship encrypted messaging faster by writing core logic once, fixing bugs once, and maintaining consistent behavior across platforms.
About This Article
X's legacy Android app and new X Lite rewrite were in separate repositories, which created dependency conflicts. Upgrading Kotlin in one codebase meant upgrading it in the other, leading to messy transitive dependency issues.
The team decided to keep the codebases separate. They chose to prioritize speed in the new repository rather than try to align dependencies perfectly between both projects.
Keeping them separate let the team iterate faster on X Lite with KMP. The tradeoff was that they had to coordinate carefully whenever they updated shared dependencies like Kotlin.