touchlab / SKIE

SKIE - Swift Kotlin Interface Enhancer
https://skie.touchlab.co/
Apache License 2.0
642 stars 8 forks source link

Flow interop not working since 0.7.0 #90

Open Tlaster opened 2 weeks ago

Tlaster commented 2 weeks ago

What is the problem?

Flow interop not working since 0.7.0

When does the problem occur?

In build/skie/binaries/debugFramework/DEBUG/iosSimulatorArm64/swift/generated/Skie, no flow related source code being generated after 0.7.0. I'm wondering if I've misconfigured the project or if there's something I'm missing.

How do we reproduce the issue?

I do have a project but it's not minimal: https://github.com/DimensionDev/Flare

What has changed since the last time SKIE worked in your project?

After upgrading to version 0.7.0 or any subsequent version.

What versions of SKIE, Kotlin, and Gradle do you use?

SKIE: 0.8.2 Kotlin: 2.0 Gradle: 8.8

What is your SKIE Gradle configuration?

skie {
    analytics {
        disableUpload.set(true)
        enabled.set(false)
    }
    features {
        coroutinesInterop.set(true)
        enableSwiftUIObservingPreview.set(true)
    }
}
TadeasKriz commented 2 weeks ago

Hey, we’ve changed the behavior that suspend and Flow interop is only enabled when your project has kotlinx coroutines dependency (making sure we don’t add it when not needed). This sounds like a bug in the SKIE resolution logic when it checks dependencies. For now, add dependency on kotlinx-coroutines-core to the module you’re using SKIE in. That should work around the problem. We’ll give your project a look tomorrow to see how we can fix SKIE. Thanks for reporting it!

Tlaster commented 2 weeks ago

Thank you for the suggestion! However, adding the dependency on kotlinx-coroutines-core did not resolve the issue.

FilipDolnik commented 2 weeks ago

Hi!

I was able to reproduce the issue. It's indeed a bug in SKIE. The issue is that the library bluesky has a dependency on SKIE runtime, which is an internal dependency of SKIE and is supposed to be only added by SKIE and not provided by anyone else.

Unfortunately, older versions of SKIE had a bug that caused this dependency to be registered in Maven, which polluted dependencies of some libraries like this one. This extra dependency creates a collision with the runtime added by SKIE and the compiler resolves that collision by ignoring both of them. The only reason why this doesn't crash the compilation is because SKIE checks for the existence of the library during compilation and disables the coroutines features if the runtime is not available.

We will need to implement a workaround in SKIE that accounts for this situation.

In the meantime, I was able to get the project working by changing the api(libs.bluesky) line in the build.gradle.kts file of the shared module to:

api(libs.bluesky.get().toString()) {
    exclude("co.touchlab.skie")
}
implementation("co.touchlab.skie:runtime-kotlin:${libs.versions.skie.get()}")
Tlaster commented 2 weeks ago

Thank you for providing the workaround, it is working correctly now!

keeslinp commented 2 weeks ago

I think I'm seeing the same issue, but I don't have a dependency on bluesky. How were you able to figure out which library was causing the problem?.

EDIT: I updated my kotlinx coroutines to 1.9.0-RC (I noticed the Flare repo was on that version) and now it seems to be working.

FilipDolnik commented 2 weeks ago

EDIT: I updated my kotlinx coroutines to 1.9.0-RC (I noticed the Flare repo was on that version) and now it seems to be working.

This seems to be a different problem. Can you please create a separate issue?

keeslinp commented 1 week ago

I'm a little hesitant because I don't actually know what fixed it/caused it and the codebase is 100% closed source so I can't really provide a repro. If I find time I'll try to walk backwards until the bug re-appears, but I don't just want to clutter your issue tracker with a very low-quality bug report if I can avoid it.