Using Kotlin from local Swift packages

Edit pageLast modified: 03 March 2025

In this tutorial, you'll learn how to integrate a Kotlin framework from a Kotlin Multiplatform project into a local package using the Swift package manager (SPM).

Direct integration diagram

To set up the integration, you'll add a special script that uses the embedAndSignAppleFrameworkForXcode Gradle task as a pre-action in your project's build settings. To see the changes made in common code reflected in your Xcode project, you'll only need to rebuild the Kotlin Multiplatform project.

This way, you can easily use Kotlin code in local Swift packages, compared to a regular direct integration method, that adds the script to the build phase and requires rebuilding both the Kotlin Multiplatform and the iOS project to get the changes from the common code.