John O'Reilly
06/19/2024, 5:24 PMShowing Recent Issues
> Could not resolve all files for configuration ':shared:swiftExportClasspathResolvable'.
> Could not find org.jetbrains.kotlin:swift-export-embeddable:2.0.20-Beta1.
sergey.bogolepov
07/05/2024, 10:37 AMKotlin.Nothing
is translated to Swift.Never
✅
• Kotlin.Any
is translated to a special KotlinBase
(partially merged, there is still a few cases left to cover).
• Support for Kotlin.Char
is WIP👷♂️
• Support for Kotlin.String
is WIP👷♂️
Note that these updates are not yet available on the Kotlin Playground:
• The first version was implemented quickly and kinda dirty before KotlinConf and we need to make some adjustments to streamline the Playground update process 🙃
Yeah, I know this is not the most exciting status update in the world, but bear with me: fun things are coming :)Peter Tran
08/13/2024, 10:18 PMxiaobailong24
08/14/2024, 5:35 PMAlexander af Trolle
08/20/2024, 6:29 PMSanjeeviraj M
09/26/2024, 1:09 PMdarkmoon_uk
10/01/2024, 1:29 AMProximityReader
, FamilyControls
and DeviceActivityMonitor
have been the newer, Swift-only API's I've needed to wrap.
Thread in Slack Conversationsergey.bogolepov
10/25/2024, 6:43 PMT?
in Kotlin becomes T?
in Swift. Interestingly, even in this relatively "obvious" case, there was a tricky issue around translating Nothing?
to Never?
:)
List, Map, Set. We decided not to reinvent the wheel here. Under the hood, the Swift export reuses existing nice Objective-C export machinery. Thanks to Objective-C - Swift interop, these NS*
collections are bridged to the corresponding Swift collections.
@Deprecated
. As I mentioned in the last post, this was a tricky topic due to multiple differences between @Deprecated
and @available
, but it seems we found and implemented a more or less consistent solution.
What's next?
Enums and Sealed Classes. As with many other features, we are starting with the most straightforward solution. Enums and sealed classes will be translated to Swift classes instead of enums, providing a user experience similar to vanilla Objective-C export, which is somewhat "meh". However, it is important for us to lay down a foundation that we can use to make Swift export more Swift-like in the future.
Extensions. We are taking a conservative approach here as well, initially exporting the extension receiver as the first parameter of a function (similar to how Kotlin extensions are exported to Java).
Why? Consider the following example Kotlin code:
class A
class B : A()
fun A.foo() = print("a")
fun B.foo() = print("b")
val a: A = B()
a.foo() // Outputs: "a" because of static dispatch
In Swift, one cannot override extensions without @objc override
, and using it to "fix" will lead to dynamic dispatch and the output "b" instead of "a".
Overrides. The Kotlin type system is much more flexible when it comes to property and method overrides. It will take us some time to find workarounds for all reasonable corner cases 🙃
Interfaces. Our next big milestone is to support the export of Kotlin interfaces as Swift protocols. Implementing a full solution (e.g., allowing a random Swift struct to implement a random Kotlin interface and be passed to a Kotlin function) is highly challenging, but we will take a step-by-step approach to tackle it.Angel Solis
11/16/2024, 6:09 PMאליהו הדס
11/18/2024, 2:16 PMJon Bailey
12/05/2024, 3:03 PMsergey.bogolepov
12/20/2024, 2:01 PMenum
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! 👋David
01/21/2025, 6:41 AMcolintheshots
01/26/2025, 9:21 PM> 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
// from androidx.compose.ui.window
import platform.UIKit.UIViewController
fun ComposeUIViewController(content: @Composable () -> Unit): UIViewController =
ComposeUIViewController(configure = {}, content = content)
Simon Frost
02/03/2025, 1:24 PMAlex Murphy
02/04/2025, 5:05 PMstruct
) export on the roadmap? From what i've seen data class exports from Kotlin will still use reference types (swift class
)sergio
02/13/2025, 8:05 AMMohamed Mabrouki
02/13/2025, 10:11 AMNadeen Ashraf
02/20/2025, 11:04 AMGrigory Panko
03/20/2025, 11:00 AMSirUnsupportedType
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?Dmitriy Tarasevich
04/19/2025, 5:43 PMmattinger
05/21/2025, 1:05 PMdata 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?Marco Righini
06/19/2025, 2:08 PMGuilherme Delgado
06/25/2025, 10:34 PMursus
07/06/2025, 1:19 AMFlow<T>
?ursus
07/06/2025, 1:24 AMHien Nguyen
07/16/2025, 9:51 AMSamuele Perricone
07/16/2025, 3:16 PMsoderbjorn
07/31/2025, 9:43 PMsuspend
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.