Kotlin to Swift technology preview
189
stars
25
commits
Swift
primary language
Aug 24, 2026
updated
This project demonstrates how to export Kotlin code as native Swift modules using JetBrains' Kotlin Multiplatform. The sample consists of three modules: :shared, :module-a, and :module-b, showcasing how to configure the DSL to export these Kotlin modules into Swift with custom configurations.
Swift Export is an experimental feature and subject to change in any future releases. It may not function as expected, and you may encounter bugs. This project serves as an early technology demonstration and is not production-ready. Use it at your own risk.
:shared - The main shared module that aggregates and exports the other modules (:module-a and :module-b) as native Swift modules.:module-a - A sample Kotlin module to be exported as ModuleA in Swift.:module-b - Another sample Kotlin module to be exported as ModuleB in Swift.The export process is configured in the build.gradle.kts file within the kotlin {} block. Below is the configuration:
kotlin {
iosX64()
iosArm64()
iosSimulatorArm64()
@OptIn(ExperimentalSwiftExportDsl::class)
swiftExport {
// Root module name
moduleName = "Shared"
// Collapse rule
flattenPackage = "com.github.jetbrains.swiftexport"
// Export external modules
export(project(":module-a")) {
// Exported module name
moduleName = "ModuleA"
// Collapse exported dependency rule
flattenPackage = "com.github.jetbrains.modulea"
}
export(project(":module-b")) {
// Exported module name
moduleName = "ModuleB"
// Collapse exported dependency rule
flattenPackage = "com.github.jetbrains.moduleb"
}
}
sourceSets.commonMain.dependencies {
api(project(":module-a"))
api(project(":module-b"))
}
}
iosApp/iosApp.xcodeproj with Xcode (tested with version 16.0)../gradlew :shared:embedSwiftExportForXcode.:module-a module is exported as ModuleA in Swift.com.github.jetbrains.modulea). Using flattenPackage, you can omit the package name and directly use classes from the module in Swift.Swift
66.8%
Kotlin
33.2%
Kotlin to Swift technology preview
189
stars
25
commits
Swift
primary language
Aug 24, 2026
updated
This project demonstrates how to export Kotlin code as native Swift modules using JetBrains' Kotlin Multiplatform. The sample consists of three modules: :shared, :module-a, and :module-b, showcasing how to configure the DSL to export these Kotlin modules into Swift with custom configurations.
Swift Export is an experimental feature and subject to change in any future releases. It may not function as expected, and you may encounter bugs. This project serves as an early technology demonstration and is not production-ready. Use it at your own risk.
:shared - The main shared module that aggregates and exports the other modules (:module-a and :module-b) as native Swift modules.:module-a - A sample Kotlin module to be exported as ModuleA in Swift.:module-b - Another sample Kotlin module to be exported as ModuleB in Swift.The export process is configured in the build.gradle.kts file within the kotlin {} block. Below is the configuration:
kotlin {
iosX64()
iosArm64()
iosSimulatorArm64()
@OptIn(ExperimentalSwiftExportDsl::class)
swiftExport {
// Root module name
moduleName = "Shared"
// Collapse rule
flattenPackage = "com.github.jetbrains.swiftexport"
// Export external modules
export(project(":module-a")) {
// Exported module name
moduleName = "ModuleA"
// Collapse exported dependency rule
flattenPackage = "com.github.jetbrains.modulea"
}
export(project(":module-b")) {
// Exported module name
moduleName = "ModuleB"
// Collapse exported dependency rule
flattenPackage = "com.github.jetbrains.moduleb"
}
}
sourceSets.commonMain.dependencies {
api(project(":module-a"))
api(project(":module-b"))
}
}
iosApp/iosApp.xcodeproj with Xcode (tested with version 16.0)../gradlew :shared:embedSwiftExportForXcode.:module-a module is exported as ModuleA in Swift.com.github.jetbrains.modulea). Using flattenPackage, you can omit the package name and directly use classes from the module in Swift.Swift
66.8%
Kotlin
33.2%