Search code examples
androidiosswiftkotlinkotlin-multiplatform

How to integrate Native SDKs for iOS and Android in a Kotlin Multiplatform project?


I am considering integrating a Native app SDK that supports Kotlin and Swift into a Kotlin Multiplatform project. I believe I can install the SDK on Android via Gradle, but I am unsure about iOS. Does Kotlin Multiplatform provide a mechanism similar to Flutter's MethodChannel? If so, I can envision the implementation. If not, how should I go about integrating it? For instance, should I perform the regular SDK integration procedures within the iosApp directory for the iOS app?


Solution

  • There are various options. Generally, create an interface in common that looks like what the common API should look like, then you implement that with native code. You can either include the dependency on Android and iOS (through cinperop), or pass an implementation in on app start.

    I gave a talk about this last year (the title on the video is wrong, bit it's the correct talk): https://www.droidcon.com/2022/06/28/sdk-design-and-publishing-for-kotlin-multiplatform-mobile/