Hello there, I'm using KMM library in my project. ...
# multiplatform
p
Hello there, I'm using KMM library in my project. I want to access local json files in both iOS and Android from shared resources. I don't want to use files from iOS App. I have written following code in shared/src/commonMain/iOSMain but its not working
Copy code
val bundle = NSBundle.mainBundle
val path = bundle.pathForResource(name = "sample2", ofType = "json") ?: "File not found"
I have put my json files in commonMain/resources/sample2.json I have also try by putting it in commonMain/resources/iOSMain/sample2.json Still its not working. Any suggestions?
f
At first, you can check if the wanted file is inside the generated iOS app, if not means the file is not copied inside the app bundle.
p
we are trying build library with kotlin multiplatform
f
Oh, you can't use
NSBundle.mainBundle
in this case
mainBundle means the application bundle
A library use a different bundle
1
p
can you please share if you have any resource for this usecase
f