I know this channel is for Swift Export, and it’s ...
# swift-export
j
I know this channel is for Swift Export, and it’s been said swift import is out of scope, but just saw a blog post from Skip.tools which does Swift -> Kotlin transpiling that they’ve added native Swift compilation for Android that can be consumed by Kotlin code. Would this help using Swift in a KMP project? https://skip.tools/blog/skip-native-tech-preview/
p
You can combine SKIP + KMP. I read a recent blog from a guy who did that. SKIP has a comand which transpiles swift to kotlin. I believe You could add that as part of the build phase and have automatic transpilation
Keep in mind skip is not free though but the price seems fair
j
I’ve seen the the transpilation before, but now they’ve added native compilation of Swift for Android (so without transpiling). So just wondered if that might help with Swift import in KMP.
p
Ah ok, I see your point. Humm, I don't see any benefit but I might be wrong. I see benefit in transpilation, since it generates kotlin code that you can call directly in iosMain so you don't have to manually inject swift wrappers and such. But generating a native binary will just add the pain to go through jni and such
j
I think they’ve done something that makes calling the Swift library from Kotlin easy, but think that will be in the next part of the blog series.
🆗 1
p
But again, unless you want to share some swift logic, which is a valuable thing, I don't see any other use case for this. The main reason people want swift imports is because of accessing the iOS swift APIs and third party libraries. On Android land, kotlin is fine, no need for swift binaries, again, unless you want to share some swift common code
a
Hello there! Thanks for the question, let me try and provide you with an answer 🙂
Would this help using Swift in a KMP project?
That depends on what exactly do you mean. If the question is "will Kotlin or official gradle plugin use Skip under the hood in order to provide swift import in nearest future" - the answer is no. If the question is "will this technology increase the speed of our development" - the answer is also no, as there is no development of swift import at this point. but we are curiously exploring the solution from SKIP, that's for sure! If the question is "is it possible for some third party to experiment and build some kind of a third party gradle plugin wrapping the solution from SKIP" - you are free to experiment (but before you do - please consult licensing on the SKIP to verify that they are OK with such) 🙂 However, mapping compiled swift to Kotlin/JVM is a very different task than mapping compiled swift to Kotlin/Native (which is the main area of concern for swift-import).
g
Just to add more info if someone ends up here without knowing what skip is:

https://www.youtube.com/watch?v=mig81rSWVqM

m
@Jon Bailey Isn't this something achieved by using something like swift-klib-plugin ? i.e: https://github.com/markst/radioplayer-kt
g
@markturnip the concepts are quite different. In short, SKIP is a transpiler that allows you to write Swift code and generate a Kotlin Compose app. It does not involve Kotlin Multiplatform (KMP) in the process. On the other hand, the swift-klib-plugin enables you to use Swift source files in the shared module of a KMP project via
cinterop
, but it is limited to the iOS target. The swift-klib-plugin is quite an interesting tool, thanks for sharing. I came across it in the past but completely forgot it existed.
❤️ 1
👍 1