Is there a way in kotlin multiplatform to include ...
# multiplatform
j
Is there a way in kotlin multiplatform to include a imagefile in the resources that later will be loadable with i.e:
image = UIImage.imageNamed("image/$file.png");
from iOS target? My current idea is using base64 and storing it common code but it would be pretty sweet if the resources-folder could be used in my static library
1
r
There is a thing called
ImmutableBlob
, which is particularly useful for accessing non-modifiable binary data, but the only way to create them is corresponding factory function: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native/immutable-blob-of.html AFAIK, there's nothing ready-made which can take your resources and represent them as blobs, but writing Gradle task converting files into Kotlin source code calling
immutableBlobOf
should be fairly straightforward.
g
I would prefer some MPP library + support from Gradle side, that would provide API to access resources and bundle src/res files to output format of target platform (Jar resources, bundled binaries on native, maybe inline to base64 on JS etc)
r
That's obviously much more desirable, I'm just suggesting a workaround.
g
yeah, sure 👍 Just shared my wishes 🙈
j
If the automatic generation also handled moving the files to a image folder inside the xcode project, I think it would be an acceptable solution
For kotlin generate a MainBundle.nameOfTheFile that contains the blob/base64 data