LouisCAD / CompleteKotlin

Gradle Plugin to enable auto-completion and symbol resolution for all Kotlin/Native platforms.
MIT License
306 stars 8 forks source link

Support for hierarchical native targets #6

Closed joffrey-bion closed 3 years ago

joffrey-bion commented 3 years ago

I struggled for a while trying to figure out what I did wrong but finally realized that the plugin doesn't seem to work for the parent ios() target, and instead only works on specific iosX64 or iosArm64 targets.

Is this a limitation of how this works? For instance, are the downloaded bindings specific to a precise platform, and there is no way to download generic iOS bindings?

Currently I find it quite painful to have to copy-paste iOS related code into iosX64Main and iosArm64Main instead of just having to write it once in iosMain.

Did I miss something here? If not, is there any workaround for this?

LouisCAD commented 3 years ago

Do you have HMPP set up in the gradle.properties file?

Which Kotlin version are you using, ans which IDE of which version are you using?

joffrey-bion commented 3 years ago

Sorry for the initial lack of information, I thought the feature was actually missing and you wouldn't need to analyze the issue.

I have the following in my gradle.properties:

kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.enableCompatibilityMetadataVariant=true

I'm using Kotlin 1.5.21, Gradle 7.1.1, and I reproduced this under IntelliJ IDEA 2021.2, 2021.2.1 (preview), and 2021.3 (very early build).

Here is my project for reference: https://github.com/joffrey-bion/krossbow It doesn't have any Apple-specific code in the iosMain target at the moment, but I'm locally trying to add some (that's why I need the plugin, because I'm developing on Windows).

Please let me know if there is anything I can do to help.

LouisCAD commented 3 years ago

You miss this:

kotlin.native.enableDependencyPropagation=false

See at the bottom of this page (which is the first Google search result for "Kotlin HMPP"): https://kotlinlang.org/docs/mpp-share-on-platforms.html#use-native-libraries-in-the-hierarchical-structure

LouisCAD commented 3 years ago

Also, I don't think you need kotlin.mpp.enableCompatibilityMetadataVariant=true.

LouisCAD commented 3 years ago

@joffrey-bion Can you confirm it resolves your issue after performing a Gradle sync?

joffrey-bion commented 3 years ago

@LouisCAD Thanks! I confirm kotlin.native.enableDependencyPropagation=false solved the problem. I didn't Google this specifically because I enabled hierarchical source sets long before I looked for supporting Native in this library ;)

Also, I don't think you need kotlin.mpp.enableCompatibilityMetadataVariant=true.

Why? According to the doc, if I don't put it then the lib won't be usable by projects that don't have hierarchical source sets enabled: https://kotlinlang.org/docs/migrating-multiplatform-project-to-14.html#migrate-to-the-hierarchical-project-structure

LouisCAD commented 3 years ago

Ah, true, you can keep it then.

LouisCAD commented 3 years ago

Closing this issue since it was a misconfiguration unrelated to the plugin itself.

If you want to add an entry in the README for other folks that might have the issue, and have an idea on where to put it exactly, and how to phrase it, feel free to send a PR.