rickclephas / KMP-NativeCoroutines

Library to use Kotlin Coroutines from Swift code in KMP apps
MIT License
1.07k stars 32 forks source link

KMP-NativeCoroutines in child modules #136

Closed smworks closed 1 year ago

smworks commented 1 year ago

I have Kmm module which I use for building xcframework. If I add @NativeCoroutines annotation on any methods or variables in that module, it seems to work as expected and I can access them in xcode project.

But if I setup KMP-NativeCoroutines in any of the child modules of Kmm module, I can see that ksp is generating code where @NativeCoroutines is used, but when exporting framework to iOS, those fields seem to become hidden or maybe not exported at all. If I move code from child module to parent Kmm module, then in xcode those hidden fields appear.

Is this expected behaviour for child modules? Any way to work around this instead of just migrating all code into Kmm module?

rickclephas commented 1 year ago

Hi. Yeah, that is kind of expected. KMP-NativeCoroutines generates extensions, which won't be part of the public API of your xcframework module.

To access those extensions from Swift, you would need to export your child module.