https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Gordon

10/09/2023, 1:06 PM
If i add a framework without CocoaPods to my KMP library, and then publish my KMP library to mavenLocal, will i be able to use this library? Will the framework binaries be packaged inside the maven repository?
j

Jeff Lockhart

10/09/2023, 3:22 PM
The framework is not packaged in the publication. You need to be sure to link the framework in the code consuming the library. I'm doing this in this example in my library. This library might be able to do what you're describing. But note it's not actively supported.
v

Vladimir Vainer

10/09/2023, 3:36 PM
But this beats the purpose. I want to distribute my kmp library with dependencies
j

Jeff Lockhart

10/09/2023, 3:46 PM
Native frameworks aren't distributed the same as Java libraries. The CocoaPods plugin helps facilitate generating a podspec to provide this dependency propagation between Kotlin and iOS native code. But this needs to be done at the shared Kotlin module layer that is consuming your KMP library. Perhaps there could be a way for Kotlin to package the CocoaPods dependency info as metadata in the .klib format for KMP library consumers. But this doesn't work this way currently.
v

Vladimir Vainer

10/09/2023, 3:49 PM
So basically there is currently no way to actually use swift / objc code in kotlin multiplatform library in a way that it will be packaged inside the library?
j

Jeff Lockhart

10/09/2023, 3:52 PM
As I mentioned above, this library was built to accomplish this. I haven't used it, and it's not actively supported.
v

Vladimir Vainer

10/09/2023, 3:55 PM
Yes. I saw that. Didn't want to use it as its not actively supported. But I must be missing something. How else can i create a kmp library that uses some native code if i can't package it? It's a major limitation.
j

Jeff Lockhart

10/09/2023, 3:58 PM
I created a KMP library that does just that. I provide examples and document how to set up consuming projects to link the proper dependencies.
c

CLOVIS

10/09/2023, 3:59 PM
How do you expect it to work? Ship the sources of the native library as part of the publication? Ship a dynamic library for each architecture as part of the publication?
v

Vladimir Vainer

10/10/2023, 9:57 AM
@Jeff Lockhart Thanks, I tried your approach, it seems to work. Not ideal, but for the lack of other alternatives, it will have to do for now. Thanks again.
👍 1
21 Views