Closed daniellfalcao closed 4 months ago
Without using the annotation, Swift can resolve the type correctly.
This is an unfortunate limitation of the KSP usage and Kotlin-Swift interop. In this case, the plugin will generate a generic extension, which is unfortunately not supported. These generics are lost in translation to Swift.
Since it seems your code is in an Apple/iOS source set, you could manually create the necessary code inside the class:
import com.rickclephas.kmp.nativecoroutines.nativeSuspend
import kotlin.native.ObjCName
@ObjCName(name = "getResult")
fun getResultNative() = nativeSuspend { getResult() }
Just annotate your original function with @HiddenFromObjC
to prevent name conflicts.
It works!!! Thank you!
I'm trying to create a generic function with the following signature:
When I call
asyncFunction
from swift where the return type of the code is anOperationResult<String>
, for example, the return of.getResult()
becomes Any. Is there anything that can be done to avoid casting on the Swift side?Ex: