rickclephas / KMP-NativeCoroutines

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

Configuration option to auto-generate wrapped coroutines/flows? #104

Open ankushg opened 1 year ago

ankushg commented 1 year ago

Pre 1.0, the library would automatically find any suspend function or flow and create an additional wrapped function. Now, we need to annotate them manually.

It would be great if there was a way to bring the automatic behavior back with version 1.0 as a configuration option

rickclephas commented 1 year ago

Hi! Agreed such an option would be really nice! Unfortunately as far as I know this isn't possible (at least not with the current Kotlin versions).

The main issue is that the NativeCoroutines annotations inherit the behaviour from the HiddenFromObjC annotation. While it's technically possible to add annotations to the IR code via a compiler plugin, that's unfortunately too late for the ObjC generation as it uses the frontend code to generate the ObjC headers.

Anyway, I'll keep this open just in case 😄.