https://kotlinlang.org logo
Title
a

ariedov

06/22/2022, 1:17 PM
Hello good people. I am looking for some ways to publish a KMM library for iOS without sharing the source code. Any tips or ideas are very welcome.
l

Landry Norris

06/22/2022, 3:05 PM
If your plan is to consume it from Kotlin, you can follow the publishing guide. You’ll need a maven hosting service. I’d recommend using GitHub’s new package registry for now, then create a Maven Central account once you’re ready. Maven Central will not share the source code.
a

ariedov

06/22/2022, 3:08 PM
Thank you, this is very useful! I plan to use it from native iOS apps though, Swift being the primary target.
l

Landry Norris

06/22/2022, 3:13 PM
In that case, I’d look into a swift package gradle plugin. I personally use https://github.com/ge-org/multiplatform-swiftpackage, but there’s also other options.
a

ariedov

06/22/2022, 3:47 PM
This is incredibly helpful. Thank you!
s

Sam

06/23/2022, 2:38 AM
I'll chime in here and say that you should consider distributing it both ways. The maven route is optimal for people that would want to consume the library from an iOS app that is using KMM. The iOS framework (via spm or CocoaPods) is good for people that just want an xcframework to add to Xcode. Of those apps ever consume a second Kotlin based framework, they'll have two Kotlin runtimes loaded into memory that can't easily talk to each other. Framework A’s Kotlin String is a different type than Framework B’s Kotlin String.
2