JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.29k stars 1.18k forks source link

Unresolved reference for windows - works on Ubuntu #3919

Closed Zyphuris55 closed 11 months ago

Zyphuris55 commented 1 year ago

Describe the bug When viewing a project, the desktop module is unable to view any shared code in windows

Windows:

Ubuntu:

Affected platforms Select one of the platforms below:

Versions

To Reproduce

  1. Create a new "Kotlin Multiplatform App" in Android Sutdio
  2. Add a "desktop" directory in the project root
  3. Add include(":desktop") to settings.gradle.kts
  4. Add below code to shared's build.gradle.kts
    kotlin {
    ...
    jvm("desktop") {
        compilations.all {
            kotlinOptions.jvmTarget = "17"
        }
    }
    ...
    sourceSets {
       val desktopMain by getting {
           dependsOn(commonMain)
       }
    }
    }
  5. Add basic linking of desktop module to shared module in desktop's build.gradle.kts

    kotlin {
    jvm {
        withJava()
        compilations.all {
            kotlinOptions.jvmTarget = "17"
        }
    }
    
    sourceSets {
        val jvmMain by getting {
            dependencies {
                ...
                implementation(project(":shared"))
            }
        }
    }
    }
  6. Sync project

Expected behavior Functions are visible in the modules, regardless of using Windows or Linux

Screenshots === Ubuntu === ubuntu_customProject

=== Windows === windows_customProject

windows_suggestedAction

Additional context Minimal example code: https://github.com/Zyphuris55/KmmTest

Zyphuris55 commented 1 year ago

Update on some testing. Kotlin 1.8.10 works kotlin 1.8.20 does NOT work (same issue as above)

1.8.20 is also when the new source set hierarchy was added. So I tried a few settings (to use "mingw" instead of desktop) and other google searched solutions, but nothing was able to resolve.

igordmn commented 12 months ago

It seems fixed in Android Studio Hedgehog | 2023.1.1 RC 3. The stable release should be soon, let's wait for it and close this issue.

It seems only Windows affected - macOs also works well.

Also tested in other IDE's.

Doesn't work:

Android Studio Giraffe | 2022.3.1 Patch 4
Build #AI-223.8836.35.2231.11090377, built on November 13, 2023
Runtime version: 17.0.6+0-b2043.56-10027231 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 32
Registry:
    external.system.auto.import.disabled=true
    debugger.new.tool.window.layout=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.experimental.ui=true

Kotlin: 223-1.9.0-release-358-AS8836.35.2231.11090377

Works:

Android Studio Hedgehog | 2023.1.1 RC 3
Build #AI-231.9392.1.2311.11047128, built on November 3, 2023
Runtime version: 17.0.7+0-b2043.56-10550314 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 32
Registry:
    external.system.auto.import.disabled=true
    debugger.new.tool.window.layout=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.experimental.ui=true

Kotlin: 231-1.9.10-release-459-AS9392.1.2311.11047128

Works:

Android Studio Iguana | 2023.2.1 Canary 14
Build #AI-232.10227.8.2321.11110254, built on November 16, 2023
Runtime version: 17.0.9+0--11084592 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 32
Registry:
    debugger.new.tool.window.layout=true
    ide.experimental.ui=true

Kotlin: 232-1.9.0-release-358-AS10227.8.2321.11110254

Works:

IntelliJ IDEA 2023.2.1 (Ultimate Edition)
Build #IU-232.9559.62, built on August 23, 2023
Runtime version: 17.0.8+7-b1000.8 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 10000M
Cores: 32
Registry:
    debugger.new.tool.window.layout=true
    ide.experimental.ui=true

Non-Bundled Plugins:
    com.jetbrains.packagesearch.intellij-plugin (232.9559.10)
    com.jetbrains.idea.safepush (232.8660.88)
    org.jetbrains.compose.desktop.ide (1.5.2)
    androidx.compose.plugins.idea (232.9559.10)

Kotlin: 232-1.9.0-IJ9559.62
Zyphuris55 commented 11 months ago

I've updated to Hedgehog (stable channel) and updated the project to use Kotlin 1.9.21/ Compose plugin 1.5.11. Project works with the correct linking of module to shared code.

There is a slight issue however regarding the dependencies, where it in some cases needs a duplicate copy of a dependency. But I can open that as a new ticket if needed if it becomes an issue.

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.