Search code examples
kotlinkotlin-multiplatformkotlin-native

How to use a swift library in kotlin native?


How can I use a Swift Library in Kotlin/Native?

I was trying out cinteropt to use objective-c libraries in Kotlin/Native but I can't seem to figure out how I could use a swift library?

Can anyone guide me here? Thanks in advance.


Solution

  • You can't interop with Swift directly, unless the Swift is designed to be consumed by Objective-C. I assume the Keychain library has Objective-C bindings available, which you should be able to interop with. If not, you can either write some kind of wrapper that would expose an Objective-C interface, or write a Kotlin interface and implement it in Swift, and pass that in to shared code.