José González
José González

Reputation: 1217

Shared resources in Kotlin Multiplatform Mobile

I would like to know how I can include some resources in the shared code of a Kotlin Multiplatform project, so those resources are available when running the shared code in both platforms. I'd like to do this for resources both in the main and test targets. I'm not talking about resources of a Compose multiplatform app, each app would have its own native UI.

To give a better picture of what I'd like: I'm developing a mobile app with iOS and Android versions and I have the following:

root-of-repo
|- dependencies
|  |- name-of-dep
|     |- ... some other files
|     |- data <- I'm interested in the files below this folder
|
|- apps
   |- android <- Android app
   |
   |- core <- shared Kotlin code
   |  |- src
   |     |- androidMain
   |     |- commonMain
   |     |  |- kotlin
   |     |  |- resources <- does this work at all?
   |     |- commonTest
   |     |  |- kotlin
   |     |  |- resources <- does this work at all?
   |     |- iosMain
   |
   |- ios <- iOS app

I would like to:

I've been reading and searching for a few hours, but there seems to be a lot of fragmented information (for example, talking about test resources but not release resources or viceversa), or seemingly contradicting information (should you use Compose resources even if you aren't using a Compose multiplatform approach?) so I'm really confused about what's the correct approach (maybe I may even manually copy the resources to a build folder??).

As a final remark, I'm well aware of expect/actual and how to load resources in each platform, my problem is to make the resources available in both platforms both for test and release targets.

Upvotes: 1

Views: 82

Answers (0)

Related Questions