Skip to main content

Build Kotlin Multiplatform iOS apps on Windows

Gradle links the shared module, and Compose Multiplatform builds too.

Build the iOS app of a Kotlin Multiplatform project on Windows, install it on your iPhone and debug it. The iosApp project and your Gradle build scripts need no changes, and Compose Multiplatform works too. Set breakpoints in both Swift and Kotlin, and step from Swift into Kotlin.

Steps

1

Set up your environment

Install Android Studio as described in the Kotlin Multiplatform docs, then install the Kotlin Multiplatform plugin from its plugin marketplace.

2

Create a project

To use an existing project, open its root folder in VS Code with File > Open Folder…, or drag the folder into VS Code. Otherwise, create one with the Kotlin Multiplatform wizard in Android Studio or on the JetBrains website, select the iOS target, and open it in VS Code.

3

Run doctor

Do this first whenever you open a project for the first time. Doctor checks your Kotlin Multiplatform setup and prepares the iOS project. The first run downloads a few hundred MB and takes a while. Run it again after you upgrade Kotlin.

Use either of these

  • VS Code extension

    In the title bar of the KXBuild view, open the ··· menu and run Doctor (fix environment).

  • Command line
    > kxbuild doctor D:\work\mykmpapp\iosApp\iosApp.xcodeproj
4

Write code

The Swift code in iosApp gets completion, go to definition and error checking in VS Code. Keep writing the shared Kotlin code in Android Studio or IntelliJ IDEA.

5

Debug

Connect your iPhone over USB, select it in the KXBuild view and press F5. In both Swift and Kotlin you can set breakpoints, step through code and inspect variables. Kotlin objects expand by class and field.

6

Release

Build with the Release configuration to get an .ipa in the iosApp folder. To upload it to App Store Connect, see Release and App Store submission.

Use either of these

  • VS Code extension

    Switch the configuration to Release in the Build configuration node of the KXBuild view, then run KXBuild: Build from the Command Palette.

  • Command line
    > kxbuild build .\iosApp\iosApp.xcodeproj -c Release

Next steps

Don't see your framework?

kxbuild is a general-purpose build toolchain, so if your framework produces an Xcode project, KXBuild can build it. The list above covers common cases only. Tell us about your setup.