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
15.97k stars 1.16k forks source link

"compose-resources" path of UIKitResourceImpl on iOS #3637

Closed SongOnWater closed 1 year ago

SongOnWater commented 1 year ago

Describe the bug Why there is a intermedia path "compose-resources" of UIKitResourceImpl , that makes files should be placed under it then to be read. I think the file path should be consistency of multiple platforms.

Affected platforms Select one of the platforms below:

igordmn commented 1 year ago

compose-resources folder is an implementation detail, and it isn't supposed to be accessed via UIKit resource API. It is designed in a way that it should be accessed only via Compose resource API (org.jetbrains.compose.resources.resource).

What is the use case where we need to access it directly?

SongOnWater commented 1 year ago

@igordmn The iOS sample project of components/resources/iosApp reports error "org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: dir/vector.xml". I think that intermedia path "compose-resources" is the root cause.

pjBooms commented 1 year ago

@SongOnWater If you use implementation(compose.components.resources) ("org.jetbrains.compose.components:components-resources") of the same version as Compose Multiplatform Gradle plugin then it should not be a root cause, because the resource library of 1.5 version prepends all resource paths with "compose-resources" itself.

igordmn commented 1 year ago

As @pjBooms mentioned, you need to use implementation(compose.components.resources). Also, see the template, it uses org.jetbrains.compose.resources.painterResource to load a resource from shared/src/commonMain/resources.

If the issue is still present, please provide a project where it is reproducible.

igordmn commented 1 year ago

As you mentioned MissingResourceException and UIKitResourceImpl, you already use the resource library, but it seems it is an older version (maybe it comes from some library).

To use a valid version, you should add it explicitly

Let us know, if adding it explicitly helps.

SongOnWater commented 1 year ago

Yes I use the library by "implementation(compose.components.resources)" and the version is as below

val kotlinVersion = "1.9.10" kotlin("multiplatform").version(kotlinVersion).apply(false) id("org.jetbrains.compose").version("1.5.1").apply(false)

To bypass this issue , I add a middle path "compose-resources" under my resources root path for iOS

igordmn commented 1 year ago

Is it possible to provide a project with the issue? Adding the path shouldn't be necessary.

igordmn commented 1 year ago

Closing, as we didn't reproduce it.

If you have a reproducer, please, attach it here, we will look at it and reopen the issue.

okushnikov commented 4 weeks ago

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