https://kotlinlang.org logo
Join Slack
Powered by
# swift-export
  • s

    sergey.bogolepov

    12/20/2024, 2:01 PM
    I'm pleased to share the latest developments in the Swift export project as we wrap up 2024! The Most Significant Changes in the Last Two Months • Implemented basic support for
    enum
    and
    sealed
    classes, which means all types of classes are covered except tricky
    value
    ones :D • Added support for simple method overrides. Not-so-basic covariant and fake overrides will come later after we implement support for interfaces. • Rolled out initial support for the
    @Throws
    annotation by translating it to an untyped
    throws
    . Current Focus Areas • Interfaces. Even though we excluded cross-language inheritance from the initial scope, interfaces remain very challenging to implement. • Functional types (aka closures/lambdas). Recently, we merged support for the
    () -> Unit
    type and are now expanding support for the rest of the possible signatures. We also need to ensure that throwing works properly, along with overrides. Oh man. Glimpse into the future For now, we are continuing to use a type system that is more or less the same as in Objective-C export (
    KotlinBase
    as the root of the class hierarchy). However, we see limitations of this approach and a potentially better option that promises to be much more flexible: KotlinBridgeable protocol. We will not switch to it before the first public release, but it is clearly something we want to explore as soon as possible. Thank you for following our progress—see you in the new year! 👋
    ♥️ 57
    👀 2
    a
    j
    a
    • 4
    • 10
  • d

    David

    01/21/2025, 6:41 AM
    Hi! Will the swift interop releases this year improve the naming of kotlin top level functions? so that you don't need to use something like this: Filename_iosKt.myFunctionCall() ?
    s
    • 2
    • 3
  • c

    colintheshots

    01/26/2025, 9:21 PM
    I was instrumenting a Compose Multiplatform app with Swift Export. I ran into this error I think because the Compose Controller function is implemented through UIKit through Objective-C. Is there a recommended solution to bring Swift Export code modules directly into a Compose Multiplatform app? Or is this simply not possible yet and I should focus on making separate Swift Export modules that don't expose any Compose code?
    Copy code
    > A failure occurred while executing org.jetbrains.kotlin.gradle.plugin.mpp.apple.swiftexport.internal.SwiftExportAction
    
       > Can't translate return type in fun MainViewController(): platform.UIKit.UIViewController: Symbol not found for platform/UIKit/UIViewController
    Copy code
    // from androidx.compose.ui.window
    import platform.UIKit.UIViewController
    
    fun ComposeUIViewController(content: @Composable () -> Unit): UIViewController =
        ComposeUIViewController(configure = {}, content = content)
    s
    • 2
    • 1
  • s

    Simon Frost

    02/03/2025, 1:24 PM
    are there any changes to swift export in Kotlin 2.1.10? didn’t see any in the change log
    s
    • 2
    • 2
  • a

    Alex Murphy

    02/04/2025, 5:05 PM
    Has anyone seen anything about value type (swift
    struct
    ) export on the roadmap? From what i've seen data class exports from Kotlin will still use reference types (swift
    class
    )
    ➕ 1
    s
    j
    • 3
    • 3
  • s

    sergio

    02/13/2025, 8:05 AM
    Hi guys! I have a question, is there any solution in development for integrate pure swift libraries into kmp with full shared ui and logic??
    f
    h
    b
    • 4
    • 41
  • m

    Mohamed Mabrouki

    02/13/2025, 10:11 AM
    hello, is there a way to import swift class that has observable propreties and be able to observe their changes in the kotlin ios code ? example swift code in thread.
    t
    • 2
    • 3
  • n

    Nadeen Ashraf

    02/20/2025, 11:04 AM
    Hello All! Does anyone know if it's possible to have a submodule in my kmp project containing a swift file, and if I can access that swift file from my main app's App Delegate ?
    x
    • 2
    • 1
  • g

    Grigory Panko

    03/20/2025, 11:00 AM
    Hi! Is there any way to track the causes of
    SirUnsupportedType
    appearing which later cause
    java.lang.IllegalStateException: Attempt to bridge unbridgeable type: SirUnsupportedType.
    ? I'm experimenting with Swift export in our project, and trying to export almost any module (trying to at least export dependencies before exporting our own modules) produces this exception. I've succeeded only with exporting single
    kotlin-stdlib
    , while having this exception with, for example,
    kotlinx-datetime
    ,
    ktor-http
    ,
    ktor-client-core
    or
    coroutines-core
    . Maybe there is some list of supported/unsupported types, or I'm just setting up something wrong?
    s
    • 2
    • 6
  • d

    Dmitriy Tarasevich

    04/19/2025, 5:43 PM
    I was eager to check out the swift export updates on the play.kotlinlang.org site but it seems on 2.20.0 it always returns Unexpected end of JSON input I know it's not done, just a heads up
    s
    s
    • 3
    • 2
  • m

    mattinger

    05/21/2025, 1:05 PM
    Hi everyone. I'm investigating using the new (experimental) swift export feature. One thing i've noticed right off the bat is that it's not handling default parameters in constructors.
    Copy code
    data class SomeClass(val value: Int = 0)
    I can't instantiate this in swift code without supplying the
    value
    parameter. I'm unable to use SKIE because we're modeling log data which has a large number of optional constructor parameters, which SKIE isn't good at handling (as it tries to create all the different permutations available) Is there something i'm missing, or is this just not something available yet?
    g
    • 2
    • 5
  • k

    kyungkoo

    06/12/2025, 1:08 AM
    Hi! Swift Export! Have you seen WWDC25 video? This video is about the interoperability between Java and Swift. Could this feature of Swift have a positive impact on kotlin-export?

    https://youtu.be/QSHO-GUGidA?si=o5exjsPksDYip33J▾

    j
    k
    f
    • 4
    • 5
  • m

    Marco Righini

    06/19/2025, 2:08 PM
    Hi! Is there any plan to expose swift export as a standalone gradle command that doesn't need to run in xcode? (e.g. for remote spm export)
    👍 3
    a
    • 2
    • 2
  • g

    Guilherme Delgado

    06/25/2025, 10:34 PM
    https://www.swift.org/android-workgroup/ 🚀
    👀 4
  • u

    ursus

    07/06/2025, 1:19 AM
    Will swift export alleviate the need for SKIE when exposing
    Flow<T>
    ?
    plus1 1
    a
    g
    • 3
    • 9
  • u

    ursus

    07/06/2025, 1:24 AM
    Will swift export make ios builds faster, slower or the same?
    a
    • 2
    • 1
  • h

    Hien Nguyen

    07/16/2025, 9:51 AM
    I have a multi-module mobile project. Android and iOS will keep their native platform UI without using KMP, but they will share business logic with each other. In the KMP business layer, we're using an umbrella framework to combine all KMP feature modules together. This was very hard to manage because each KMP feature module is managed by a different team. I have a question: I have a KMP module called Manager. In this Manager module, there is a class called FeatureManager that contains a list of FeatureInterfaces. The FeatureInterface will be used by other KMP modules like moduleA and moduleB to create classes that implement these FeatureInterfaces. The register method of FeatureManager will be called in the iOS app. Now I have upgraded to Kotlin 2.1.0. I want to stop using the umbrella module. Instead, each KMP module will create its own framework, and the iOS app will consume these frameworks. Is this possible for my above problem relating to Manager and moduleA, moduleB?
    g
    h
    • 3
    • 8
  • s

    Samuele Perricone

    07/16/2025, 3:16 PM
    are there any udpates to swift export in Kotlin 2.2.0 or newer betas? (like Kotlin 2.2.20-Beta1)? didn’t see any in the change log, but the YouTrack ticket mention that swift export is planned for 2.2.20-Beta2, thanks to the Jetbrain team that is working on it! 🙇
    c
    a
    • 3
    • 2
  • s

    soderbjorn

    07/31/2025, 9:43 PM
    I'm trying out 2.2.20-beta2 with the Swift export! 😍 However, I have a problem with
    suspend
    functions. In the past they were exported to ObjectiveC and very easy to call from Swift, e.g.:
    viewModel.run() { error in
    if let error = error {
    // ...
    }
    }
    Now, looking at the generated Swift source code, my
    suspend
    functions are completely excluded from export! 😱 Other functions in the same class are exported, even with similar (empty) method signature, as long as they are not
    suspend
    functions. I must be missing something here. What might be going on? 🤔 Edit: Hmm, I guess this is probably just a consequence of coroutines not being supported yet.
    😢 5
    g
    a
    f
    • 4
    • 4
  • r

    russhwolf

    08/06/2025, 5:05 PM
    Hi! I watched the video from @Artem Olkov's KotlinConf talk (sorry I missed it live) and appreciate the spreadsheet at http://kotl.in/swift-export-feature-status that shows Swift Export status by feature. One bit of feedback: It'd be helpful to have a distinction between "Not supported, but planned for the future" and "Not expected to ever be supported" (due to technical limitations or whatever)
    👀 4
    👌 6
    a
    s
    +2
    • 5
    • 11
  • j

    Jaypalsinh Barad

    08/10/2025, 8:06 AM
    is swift export support cocoapods or not?
    f
    • 2
    • 2
  • c

    Cees Wiersma

    08/14/2025, 1:18 PM
    Trying out swift export in 2.2.20-beta2, but keep getting an exception:
    Copy code
    Caused by: java.lang.IllegalArgumentException: Collection contains more than one matching element.
    	at org.jetbrains.kotlin.swiftexport.standalone.builders.BuildSwiftModuleKt.buildSirSession(buildSwiftModule.kt:148)
    	at org.jetbrains.kotlin.swiftexport.standalone.translation.ModuleTranslationKt.translateCrossReferencingModulesTransitively(ModuleTranslation.kt:110)
    
    	at org.jetbrains.kotlin.swiftexport.standalone.SwiftExportRunnerKt.translateModules(SwiftExportRunner.kt:167)
    
    	at org.jetbrains.kotlin.swiftexport.standalone.SwiftExportRunnerKt.runSwiftExport(SwiftExportRunner.kt:139)
    
    	at org.jetbrains.kotlin.gradle.plugin.mpp.apple.swiftexport.internal.SwiftExportAction.execute(SwiftExportAction.kt:55)
    Is this something worth creating an issue for on YouTrack or simply a configuration mistake on my end?
    a
    • 2
    • 3
  • j

    John O'Reilly

    08/24/2025, 10:16 AM
    With initial versions of Swift Export not supporting concurrency interop will it be possible to continue using likes of SKIE alongside Swift Export in the meantime?
    ➕ 2
    j
    r
    +2
    • 5
    • 6
  • j

    John O'Reilly

    08/25/2025, 6:27 PM
    I was looking to try out recent 2.3.0-dev build but looks like following dependency is a couple of weeks behind main dev builds (it's on 3616)....is that expected right now? https://packages.jetbrains.team/maven/p/kt/bootstrap/org/jetbrains/kotlin/android/org.jetbrains.kotlin.android.gradle.plugin/
    j
    • 2
    • 3
  • j

    John O'Reilly

    08/25/2025, 8:24 PM
    I've been using branch of one of the KMP samples I have (https://github.com/joreilly/chip-8/tree/swift_export) to try out Swift Export. Am using Kotlin dev version (that has fix for https://youtrack.jetbrains.com/issue/KT-79785 which I had previously encountered in that sample). Shared code is building fine now (am using
    embedSwiftExportForXcode
    etc) and now at point where seeing some issues with some of the Swift code I'm using.....more in 🧵
    a
    g
    • 3
    • 19
  • s

    Siggi Gunnarss

    09/03/2025, 11:33 AM
    Am I misunderstanding things or are there architectural issues with Swift export and distributing compiled Swift packages? Will we need to switch to
    embedSwiftExportForXcode
    to use Swift export for the foreseeable future? https://kotlinlang.slack.com/archives/C073GUW6WN9/p1750342126794569 https://youtrack.jetbrains.com/issue/KT-78747/Swift-export-for-SPM
    g
    a
    m
    • 4
    • 15
  • a

    Arsildo Murati

    09/03/2025, 11:32 PM
    Hi, are we able to export modules with compose code inside of them using swift export? I am trying to achieve this after looking around in slack if I am not mistaken we are not able to do this?
    a
    g
    • 3
    • 36
  • r

    rudolf.hladik

    09/05/2025, 8:37 AM
    Hi everyone, I've tried
    export-kdoc
    feature with swift export and it doesn't work. Is there a plan to support it? Is there other way how to show doc comments from shared code to our fellow iOS devs? we used dokka with gh pages for public repos but for private ones it is no go coz gh pages are public.
    ➕ 1
    a
    s
    • 3
    • 2
  • s

    spencer

    09/09/2025, 10:41 PM
    Hi, i'm trying to get swift export to work in my project using kotlin 2.2.20-RC2. I'm getting an error that the java heap space is full after a gradle daemon is forked, and I can't figure out how to change the jvm args for the daemon worker.
    a
    p
    • 3
    • 8
  • g

    Ghasem Shirdel

    09/19/2025, 1:15 PM
    Hello 👋, I’ve recently been exploring the new Swift Export feature and created a small sample module with a foo class and a bar function. While reviewing the generated Swift Export code, I noticed that it seems to be essentially the Objective-C output wrapped with Swift code. Could you clarify if that’s actually the case, or if Kotlin code is being directly converted into Swift syntax? I also have a couple of related questions: 1. Do you have an estimated timeline for when this feature will become stable? At the moment, configuration feels quite complex, and from what I’ve read, each opt module needs to be exported separately. 2. In my sample, the module contains Compose code, and I encountered errors regarding mismatched input names (along with a few other related issues). Thanks in advance for your clarification and guidance!
    a
    • 2
    • 2