Kotlin-native: Add Apple Combine Framework platform lib

Created on 23 Mar 2020  路  16Comments  路  Source: JetBrains/kotlin-native

Most helpful comment

How does Kotlin/Native limit your ability to write UI code in Swift?

I was just trying to create shared ViewModels with Flow that could be used in SwiftUI. But that requires the implementation of some of the Combine Framework's interfaces.

It doesn't block me from writing iOS code, but my fear is that this is something that will happen more often from now one as Apple focuses solely on Swift.

All 16 comments

Hello, @nbransby! As I understood from the documentation, this framework is Swift-only. Therefore, it will not be possible to provide correct interoperability with it right now.

@artdfel sorry if it's not the right place. I'm new to Kotlin Native and was specifically looking to this library to create view models that work with SwiftUI.

I googled a bit but couldn't find it. What's the current state of the pure Swift interop? Is it on the roadmap? Is it being developed? Is there a forecast of when will it happen?

I ask this to help me make a decision on whether to go with Kotlin Native or not. I find Kotlin Multiplatform amazing, but I believe Apple will more and more focus on Swift-only libraries. If Swift interop doesn't come any time soon, I fear that choosing Kotlin Native will limit us in the near future.

What's the current state of the pure Swift interop?

It is on our roadmap, without specific ETA.

but I believe Apple will more and more focus on Swift-only libraries. If Swift interop doesn't come any time soon, I fear that choosing Kotlin Native will limit us in the near future.

How does Kotlin/Native limit your ability to write UI code in Swift?

How does Kotlin/Native limit your ability to write UI code in Swift?

I was just trying to create shared ViewModels with Flow that could be used in SwiftUI. But that requires the implementation of some of the Combine Framework's interfaces.

It doesn't block me from writing iOS code, but my fear is that this is something that will happen more often from now one as Apple focuses solely on Swift.

I see. Thank you for the reply!

Same use case for me, the ViewModels for SwiftUI need to extend Combine.ObservableObject to be able to "refresh" the view. As a workaround I am wrapping every Kotlin view model in Swift but that is a lot of work.

@Thomas-Vos that's exactly what I was trying to avoid :)

It would be nice to have platform-specific code JUST for UI and Navigations, everything else shared. In the end, all the views are the same (or have the same functionality) anyways.

But my biggest concern in this whole story, what I've been through a few times is:

A company decides to adopt a specific technology because it believes it's the future (and I do believe Kotlin Native is the future), all works well until something new comes up. Then, after this something new comes up, the platform you chose decide not to adopt it, or at least not anytime soon.

I do believe Apple will more and more implement swift-only libraries. And it's a bit concerning that supporting this is not on the roadmap. That means that with every new iOS release from now on, Kotlin Native adopters will fall short on something.

And it's a bit concerning that supporting this is not on the roadmap.

@thiagorp I'm not sure what do you mean by the last message, as @SvyatoslavScherbina explicitly stated the following:

It is on our roadmap, without specific ETA.

Please give it some time, there are far too many things to work on in Kotlin/Native and Kotlin/Multiplatform. Eventually direct Swift interop will appear. Note that generics support, which is basically exclusive to Swift, have already landed recently. That should be a good sign that Swift would definitely get some additional love in future :)

@thiagorp I'm not sure what do you mean by the last message, as @SvyatoslavScherbina explicitly stated the following:

I put it poorly, sorry. Just felt like it won't be worked on anytime soon. But I didn't mean anything bad.

That's great to know that Swift is getting additional love! I have really high hopes for Kotlin Native. Developing for Android in Kotlin has been a pleasure! I hope we can bring it everywhere.

Thank you all for the support!

(Closing this particular issue because it is generally a part of a bigger task)

Is there a link to that issue?

By "bigger task" I mean supporting using Swift libraries in Kotlin. There is no issue for it yet, because we don't need it for the development process. Do you need the issue to track the progress on the task?

Yes. Swift libraries support is parent task. But I imagine that Combine could have similar compatibility with Coroutines as RxJava has. It would be useful since SwiftUI has native support for Combine.

It's handy to have a dedicated issue to track if/when such functionality is considered/added.

"Combine could have similar compatibility with Coroutines as RxJava has" is not a subtask of "Swift libraries support". The latter is the prerequisite for the former, but that's it, no other links between these two features exist.

Please create a feature request for kotlinx.coroutines library if that's what you imply here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benasher44 picture benasher44  路  4Comments

Marcopohlo picture Marcopohlo  路  4Comments

brettwillis picture brettwillis  路  4Comments

AregevDev picture AregevDev  路  3Comments

ghost picture ghost  路  4Comments