Hi everyone! :wave: I'm trying to integrate a nati...
# multiplatform
b
Hi everyone! 👋 I'm trying to integrate a native Swift SDK (Vapi) into my Kotlin Multiplatform project using Compose Multiplatform. The SDK is written in pure Swift and uses modern features like async/await and Combine. Here's my current setup: - Fresh KMP project created with the wizard - Using Compose Multiplatform for UI - Need to implement Vapi SDK natively in the iOS module The main challenge is: How can I properly bridge this Swift SDK to make it accessible from my shared KMP code? I've seen some solutions mentioning creating a wrapper and using interfaces, but I'm not clear on the exact steps. Specifically: 1. Where exactly should I create the Swift wrapper file? 2. How do I make it visible to my Kotlin code? 3. What configuration changes are needed in build.gradle.kts or other project files? Any guidance on the proper way to set this up would be greatly appreciated! 🙏
f
m
You can check this out: https://medium.com/@mofeejegi/calling-platform-specific-dependencies-in-kotlin-multiplatform-69dbc9a841a2 I wrote it a while ago but it should still be relevant
f
Mmh, the SDK is not a cocoapods nor a xcframework. So you can’t import directly the SDK, so the solution of @Mofe Ejegi could work
also, https://github.com/ttypic/swift-klib-plugin, but only when importing external dependencies have been implemented.
j
Are you using DI like Koin? I would use common interfaces for Platform specific API's. DI helps you inject the native implementation and bind to the common interface. But you could do without DI framework also.
f
Yes, you don’t need to you DI framework. An interface in kotlin and the implementation in Swift. You’re injecting from your app your SDK methods
b
First of all thank you very much for replying! I have implemented what you chatted about and it works both with DI and without DI. My last question is, what do you recommend? Implement DI or is it not necessary? Thank you very much!
f
For just implementing your iOS SDLK to your kotlin app, no need a DI (like koin); it depends of what do you want to do