Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News JetBrains Compose Multiplatform for iOS Reaches Alpha

JetBrains Compose Multiplatform for iOS Reaches Alpha

After adding support for desktop apps and the Web, JetBrains multiplatform declarative UI toolkit now runs on iOS in alpha.

Based on Google Jetpack Compose, recently updated with improved performance and extensions, Compose Multiplatform runs natively on Android and, thanks to Kotlin Multiplatform on Windows, Linux, macOS, and the Web, too. The addition of iOS extends Compose Multiplatform to all major OSes.

The approach followed by Compose Multiplatform is to provide the same API across all supported platforms, replicating Jetpack Compose APIs:

The APIs in Compose Multiplatform are the same ones that have already been tried and tested in Jetpack Compose. That means developers who have experience writing modern Android user interfaces using Jetpack Compose can transfer those skills directly to write a shared user interface with Compose Multiplatform, targeting iOS and beyond.

This includes state management, layout composition, and animations. For a number of features that are strictly OS-dependent, like loading resources, Compose Multiplatform provides its own higher-level abstractions to maximize portability.

On iOS, Compose Multiplatform uses canvas-based rendering, using the Skiko graphics library. Also known as Skia for Kotlin, Skiko is based on Skia, Google's graphics library used for Chrome, ChromeOS, and Flutter.

This approach means that Compose Multiplatform apps have the same look and feel across all supported platforms, similarly to Flutter apps. Unlike Flutter, though, Compose Multiplatform provides Material and Material 3 widgets out of the box, so Compose Multiplatform apps will just look like plain-vanilla Android apps. While Material is the only widget look-and-feel currently supported on iOS, JetBrains has not yet made a final decision about whether to provide a native widget look-and-feel.

An important aspect of creating cross-platform apps is interoperability with the underlying OS SDK. Compose Multiplatform for iOS provides a two-way interop layer on top of UIKit, with two main classes, UIKitView and ComposeUIViewController. UIKitView enables embedding platform-specific widgets like maps, web views, media players, and camera feeds within a Compose UI. ComposeUIViewController can be used instead to embed Compose screens in UIKit and SwiftUI applications. This can be helpful to gradually convert an existing app into a Compose app.

To start working with Compose Multiplatform for iOS, you will need a machine running recent version of macOS, Xcode, Android Studio, and the Kotlin Multiplatform Mobile plugin. All additional dependencies can be managed through CocoaPods.

The best place to start is one of the project templates provided by JetBrains. Those include a basic iOS/Android app, an image viewer, a chat app, and many more. A number of tutorials are also available to guide you through using the most common UI elements in a Compose Multiplatform app.

About the Author

Rate this Article