Jhaman das

01/16/2023, 10:57 AM
Hello, Is there any way to write files in resources in shared module so it can be read for both iOS and Android. Most probably pdf files to download and save to resources folder for KMM project


01/16/2023, 1:50 PM
Have you looked at We are using it for shared localisation files, but have not tried sharing resources yet.

Jhaman das

01/16/2023, 2:10 PM
Yea i have seen this, is there any way to access the file in shared module

Jeff Lockhart

01/16/2023, 5:05 PM
I found it necessary to symlink the Android resources directory to the common resources. For iOS I had to create a gradle task to copy the common resources to the framework or binary run path. I created this YouTrack issue when I initially found this need for common resources in tests. I've since had the same need in production modules and used the same workaround. Ordinarily I'd expect to be able to add the common resources path to the platform src sets. But if you do this, the IDE will remove the src paths with the error: "Duplicate content roots detected", as the IDE doesn't support having the same source directory belong to multiple modules or source sets. Symlinks work as a workaround as the IDE sees the files as unique paths. This has some odd side effects, like those files showing up twice in search results though. For resources it's less of an issue than actually source code, which has additional side effects like the in-memory cached and on-disk states becoming conflicted when doing refactor or find/replace operations on the symlinked files.