touchlab / KaMPKit

KaMP Kit by Touchlab. A collection of code & tools designed to get your mobile team started quickly w/Kotlin Multiplatform
https://touchlab.co/
Apache License 2.0
2.2k stars 199 forks source link

Not possible to debug suspend functions #118

Closed mpivchev closed 2 years ago

mpivchev commented 4 years ago

Whenever I try to debug a suspend function I get the following error:

image

From what I've read online it used to not be possible to debug suspend functions but apparently this has been resolved now. Is it still impossible for MPP?

kpgalligan commented 4 years ago

"used to not be possible to debug suspend functions but apparently this has been resolved now" JVM or native? The error message is blocking your code. Is the breakpoint in the body or where it's being called?

mpivchev commented 4 years ago

Native. The function is the getBreedsFromNetwork function from your example. Nothing has been changed. I just tested it because our project's Native Kotlin code also can't be debugged.

samhill303 commented 4 years ago

I think we will re-evaluate this once kotlin 1.4 is ready and see if there is still an issue then

headsvk commented 4 years ago

I'm also trying out the debugger and it's not working on suspend functions and flow. That's a shame.

kpgalligan commented 2 years ago

This is pretty old, but I think we can look and close now that we're on 1.6.10.

The debugging isn't a "KaMPKit" thing as much as a Kotlin compiler and tooling thing. I would try this in the Xcode plugin, and make sure the breakpoint is on "code" and not on a bracket, etc.

We are revisiting the Xcode plugin now, so probably some "tips and things to avoid" wouldn't be bad.

kpgalligan commented 2 years ago

Added https://github.com/touchlab/xcode-kotlin/issues/48 for follow up later.

russhwolf commented 2 years ago

This seems to be largely working for me.

I can successfully stop at breakpoints inside suspend functions on Android Studio 2021.1.1 with KMM Plugin 0.3.1, and inside Xcode with the lastest version of the plugin. The one weirdness I encountered was that, in unit tests, I wasn't able to debug a line with a lambda (eg log.d { "Fetching Breeds from network" }) in Android studio. But it works when the app is live.