Is it possible to use a pure Swift Library for Kot...
# kotlin-native
a
Is it possible to use a pure Swift Library for Kotlin Native using cinterop? I know that as is, that is that possible, but is there any way or work around that I could do to make this work?
o
Only saw something like this: https://github.com/KodeinKoders/playground-SwiftLib-in-KMMLib (Haven’t tried it on my own)
a
hi @Oleg Yukhnevich Thanks for sharing. By any chance have you tried doing the same?
o
Nope, but have plans for try it near future (not required at the moment)
a
I looked into the project looks like it is a prerequesite that the library is annotated with
public
and
@objc
. Looks like the same way that
native.cocoapods
work.
o
AFAIK the idea is to create your own mini-library in Swift with
public
+
@objc
which under the hood will use other Swift library (which you want to use)
a
I’ll try and experiment on this as well. Looks like I have to wrap the swift library into my own library that would support cinterop (through
public
+
@objc
).
d
We've just done this at work by creating an ObjC wrapper library. For a Swift API of moderate complexity; you'll be encountering not only the simple case of applying
@objc
annotation to 'pass through' functions, but also re-modelling Swift `enum`s as ObjC class structures, where these might be used to express data going to/from the API. It's leg-work, but overall not too challenging.