Hi there, I’m approaching to KMM for my app agency...
# multiplatform
r
Hi there, I’m approaching to KMM for my app agency. We’re developing native iOS and Android apps from 9 years and we’ve followed KMM from its start but we’ve not switched to it yet. I’ve evaluated KMM two years ago and last year but some limitations at the iOS side stopped me to start using it. Now I’m here again to see what changed in the past year and I see that many things have improved and the new memory management is in Beta (from 1st August) but I see that it’s not possibile to use pure-swift dependency yet. I’ve just investigated the roadmap and I haven’t seen any trace about it. In my opinion the swift community resources are still growing and many of them are very mature and stable - we use many of them in our apps in production and we feel confident about them; Apple itself is releasing new SDK only in pure swift (see CryptoKit). I don’t know if switching to KMM leads us to a path in which we couldn’t use official sdk or great and community supported dependencies because they’re pure swift. What do you think about it? Am I wrong? Is it just a step forward take any great pure swift sdk or pod and add objc bridge to use it in KMM? Please note our scenario: we aren’t a company with one or few apps in which we could decide about what to do and what to do not; we are an agency that develop 15-20 apps any years for different customers and we wish to be able to answer “yes” at customers question when asking “is it possible to do this?” - for example using a third-part service sdk or newest Apple sdk both with in pure swift. Thank you for any suggestion and advice
r
Direct Swift interop has indeed been postponed: https://youtrack.jetbrains.com/issue/KT-49521/Support-direct-interoperability-with-Swift
we wish to be able to answer “yes” at customers question when asking “is it possible to do this?” - for example using a third-part service sdk or newest Apple sdk both with in pure swift.
That shouldn’t be a problem. While you can’t directly use pure Swift dependencies, you could create an ObjC bridge to use it in Kotlin. Or (although not as flexible) you could define interfaces in Kotlin and implement them in Swift.
a
r
we’ll take the next steps to promote it to Beta and enable it by default.
Correct, but Kotlin 1.7.20-Beta enables the NMM by default, so that would mean it will be promoted to beta very soon.
r
Thank you @Rick Clephas for your answer. The solution you propose is interesting, but is feasible every time? For example, I see that Amazon Amplify iOS library are pure swift sdk - we don’t use them, it’s just an example of a big dependency - in your opinion is Objc briding still a way to follow? In our experience as big dependency I think about HereMaps or VXG Media Player or Vuforia (Augmented Reality SDK).. if they are or will be pure swift make some bridging could be very time consuming.. again, am I wrong?
r
No you are correct. In case of a library with a large API that would indeed be quite time consuming. The great thing about KMM is that you don’t have to use Kotlin for everything. You can look at the effort needed to create ObjC bridges and decide for yourself if it’s worth it or not. Worst case scenario you endup with two native implementations with less shared Kotlin code then you would have hoped for.
r
Ok thank you very much! your feedback is very useful.. let’s start some KMM 😎 Another question, if I can: actually our team is very strong in Rx stuff.. is it better to don’t try to insert it in a KMM project and switching to coroutines instead?
r
I would use coroutines in Kotlin. It’s really well integrated in the language (and makes the most sense for Android as well). Though that does have some challenges when exposed to ObjC/Swift. I actually created a little library to help with that: https://github.com/rickclephas/KMP-NativeCoroutines (feedback is always welcome! 😇)