Kasikornbank Aug 2, 2023

Quick Preview Compose Multiplatform in Our Existing Project

Article Summary

Sinj Menarucho from KBTG took Compose Multiplatform for iOS (still in Alpha) for a test drive with an existing native project. His verdict? Promising, but not production-ready yet.

This hands-on POC explores integrating Compose Multiplatform into an existing native iOS/Android project to share UI code across platforms. The author migrated actual Jetpack Compose screens from their production Android app to test real-world viability on iOS, documenting every integration challenge along the way.

Key Takeaways

Critical Insight

Compose Multiplatform can technically share UI between iOS and Android today, but Alpha-stage limitations, integration complexity, and UX issues make it better suited for future projects than current production apps.

The author hit a showstopper that prevented testing on real iOS devices entirely, revealing a critical gap in the current Alpha release.

About This Article

Problem

Sinj Menarucho's team ran into a wall when trying to access resource files like fonts and images in their Compose Multiplatform project. The standard Android syntax R.font.XXXX and R.drawable.XXXX didn't work, which prevented them from integrating UI components from their existing native codebase.

Solution

They switched to the moko-resources plugin through MOKO's template fork. This gave them pre-configured resource handling and let them reference assets using MR.fonts and MR.images syntax instead of the standard Android R class.

Impact

The resource workaround made it possible to build and run the app on both iOS and Android simulators. The same Kotlin Compose code rendered the CardMain screen identically across both platforms without needing platform-specific changes.