Are there any plans written out for Kotlin Native ...
# kotlin-native
a
Are there any plans written out for Kotlin Native for future development related to potential features like bitcode support or generics? I didn't find anything on the repo or by skimming the blog.
g
As I know current plan to have smooth ObjC interop (so no generics, only for collections), direct Swift interop as I understand is not in work now and requires some additional consideration
a
What do you mean with direct Swift interop? I'm definitely no Swift expert by any stretch of the imagination.
We're currently looking at some options for a shared library between Android and iOS.
g
Because there are no generics in ObjC
but Kotlin Native goal is ObjC interop, because it allows to use K/N from Swift and ObjC and use ObjC API (all iOS APIs as I understand)
K/N has limited generics supports for collections, to be type safe for Swift, but full blown swift generics support is not so easy as I know
So “direct Swift interop” means for K/N to generate some Swift-specific bindings, not only ObjC-specific
a
Hmmm, is there any way to compile from Swift to Kotlin or something for shared libraries? We're looking at some stuff, but there isn't a whole lot available (and documentation is lacking on the projects that we do find).
g
compile from Swift to Kotlin? What do you mean?
K/N can be compiled to iOS framework
and can be used from Swift
a
We had a look at some examples, I think the best thing to do is to just try it out and see whether it works for us. Thank you 🙂
Is there any documentation available though when it comes to separating the shared library, Android code, and iOS code? I assume that the shared library can be made available on an internal Maven repo, but is that also possible for iOS (not Maven I assume then)?
g
What do you mean “separating the shared library”?
It’s not actually “shared library” like
.so
, so you do not share binaries for Android and iOS, this approach based on Kotlin Multiplatform Projects https://kotlinlang.org/docs/reference/multiplatform.html
So you compile your project for each platform and get separate results: aar for Android, framework for iOS. You can publish aar to Maven, for iOS probably make sense to publish as CocoaPod. otherwise not sure how would you use this dependency from maven on iOS
a
Yes, I don't mean
.so
shared libraries. I mean separate builds. Alright, I'll have a look around on how to publish it as a CocoaPod. But that's what I was looking for, whether it was possible at all.
g
result of K/N compilation is binary iOS framework, so should be possible to publish as a CocoaPod, but never tried
Also, I would start not from publishing, but just from compilation and add framework to your iOS project manually, just to be sure that everything is fine
a
Alright, will do. Thank you.
y
Andreas, we’re using K/N to build a cross platform framework to be used in our android and ios apps. We’ve also delivered the framework as a cocoapod to be used by the mobile UI team. Let me know if you have any questions
a
@yusuf3000 how do you handle versioning between the shared library and one of the apps? Are you using a Git submodule or something? But I haven't heard the greatest thing about them.
I tried out companion objects, but it's a bit clunky because it's a separate object that you have to instantiate. Will this be "converted" to static in the future?
y
We’re using cocoapods to handle versioning for the iOS app. We wanted to avoid git submodules too.
a
But what do you do if you need to go back to a previous release to fix a bug and you need to work on the shared library as well?
y
Using companion objects isn’t too bad. You can write
CompanionObject.init()
which will give you the non companion object. I’m also aware that there is a github issue where the syntax will become nicer from the ios side, but it will be the same functionality.
a
Also how do you handle stuff like datetime, seems like something crucial.
y
Our K/N framework isn’t being used in production yet, so we haven’t come across this issue yet, but yes it’s something for us to think about too.
You can use the
expect
actual
feature of Kotlin MPP to use the platform api’s for things like Date and Time
that’s what we have done in our project