Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access exposed resource from core module (iOS) #4392

Closed
mpierucci opened this issue Feb 29, 2024 · 5 comments
Closed

Can't access exposed resource from core module (iOS) #4392

mpierucci opened this issue Feb 29, 2024 · 5 comments
Assignees
Labels
bug Something isn't working ios resources

Comments

@mpierucci
Copy link

Describe the bug
In order to bypass the current limitation of multi modules ntonotsupported, we add all the resources in a core module and then expose them through composable functions.
This works as expected on Android, but on iOS we get the exception:
org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: values/strings.xml
Reproducer Project

Affected platforms

  • iOS

Versions

  • Kotlin version*: 1.9.22
  • Compose Multiplatform version*: 1.6.0
  • OS version(s)* (required for Desktop and iOS issues): 15
  • OS architecture (x86 or arm64): simulator

To Reproduce
Steps and/or the code snippet to reproduce the behavior:

  1. Clone the provided reproducer project
  2. Run the iOS App
  3. Click on "Click me!" Button
  4. See error

Expected behavior
The app should not crash on iOS and the resource should be shown.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Note that the reproducer project was created with the late wizard and was only modified to expose the resources from a resource module.
Running the android app does not have any issues

@terrakok
Copy link
Collaborator

terrakok commented Feb 29, 2024

In order to bypass the current limitation of multi modules ntonotsupported, we add all the resources in a core module and then expose them through composable functions.

resources must be in the top level app module

@terrakok
Copy link
Collaborator

#4229

@mpierucci
Copy link
Author

mpierucci commented Feb 29, 2024

In order to bypass the current limitation of multi modules ntonotsupported, we add all the resources in a core module and then expose them through composable functions.

resources must be in the top level app module

Does that means that is there no work around at all for project with feature modules? Essentially not being able to use the library at all?

If so is there a rough estimate on when would that be possible? ( Just to decide if we can wait or we should pick another library)

Also why does it works on Android builds?

@terrakok
Copy link
Collaborator

The first dev builds will be available soon but it will rtequire the kotlin gradle plugin 2.0+

It doesn't work as you expected on the android target. JVM ecosystem has binary for each module (jars) and it supports resources. Kotlin ecosystem doesn't have a resources support yet.

LaputaZeej added a commit to LaputaZeej/HDVirtuals that referenced this issue Mar 28, 2024
问题:compose插件会根据CompseApp下/composeResources/里的文件生成Res类和Resource0类,但是在lib-module下iosApp使用会报错MissingResourceException。JetBrains/compose-multiplatform#4392
解决:暂时使用接口HDResProvider依赖注入ComposeApp生成的资源。同时引入ksp想通过ksp自动生成HDResProvider的实现类,避免手动注入。
2.引入voyager完成导航功能。
3.添加设备列表、添加设备页面。
@okushnikov
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios resources
Projects
None yet
Development

No branches or pull requests

4 participants