I'm creating a KMP Library for mobile (Android and...
# multiplatform
s
I'm creating a KMP Library for mobile (Android and iOS) I need an Xcode package to support the iOS side of things. I have the URL to this Xcode Package. How can I add this Xcode Package to my KMP Library's dependencies for iOS?
j
The easiest way imo if library compliant as cocoapods: https://kotlinlang.org/docs/native-cocoapods.html For SPM, its possible with some tweaking: https://johnoreilly.dev/posts/kotlinmultiplatform-swift-package/ Also make sure library is objc supported to use from your Kotlin code.
s
Thank you. It's using SPM. The article describes how to import one in a KMP Application. I'll check if something similar can be done for a KMP Library.
p
One option could be separating your library in two binaries, the .klib and the swift package. Clients will add the package in a standard way using Xcode ui or Package.swift, and they will add the kmp .klib in a standard way just adding the maven coordinate in iosMain.
s
That's indeed an option, but i hope to avoid that, to make it easier for the users of my KLIB that i'm publishing. My KLIB is basically a 'wrapper' around a 3rd party library that is available separately for both Android (plain maven/gradle dependency) and iOS (SPM). This wrapper abstracts commonalities into one KLIB api that then can be used by other people's
commonMain
of their apps. No extra work needed, just a gradle dependency in
commonMain
for users of my KLIB.
💯 1