moko-resources
moko-resources copied to clipboard
XcFramework kotlin.IllegalArgumentException: bundle with identifier com.organtis.shared.MR not found
This is some kind of question regarding generated strings bundle for ios. I faced the problem that the iOs app can't get shared String resources by provided ID on the ios simulator. Found this thread, but seems like I have another case: slack thread
- Ios application and KMP module are in different repositories.
- I distribute the ios xcframwork using kmmbrige plugin (as SPM) ( I can see
projectName/shared.bundlein theshared.frameworkzip file) - followed the README of the SDK during the configuration.
- If I build xcframework locally by using assembleXcFramework I faced the same issue ( I can see
projectName/shared.bundlein theshared.frameworkdir) - xcframework is build as non static (isStatic = false)
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = SHARE_BINARY_NAME
export(libs.moko.shared.resources)
}
}
multiplatformResources {
multiplatformResourcesPackage = "com.example.shared"
multiplatformResourcesClassName = "SharedRes"
iosBaseLocalizationRegion = "en"
}
-
Also I can see them in generated files:
-
I can get access
iosMain:
actual class Strings {
actual fun get(resId: StringResource, args: List<Any>): String {
return if (args.isEmpty()) {
StringDesc.Resource(resId).localized()
} else {
resId.format(*args.toTypedArray()).localized()
}
}
}
Try to get generated string by ID in iOs app using actual Strings implemetation. (not worth to mention, I also tried get string value using SharedRes.strings().my_string.desc().localized(), and I got the same result)
Strings().get(resId: SharedRes.strings().payment_error_title, args: [])
as a result, I receive an exception: kotlin.IllegalArgumentException: bundle with identifier com.example.shared.MR not found
- shared module gradle tasks https://docs.google.com/document/d/1Fzp-96ONL-N2Fmk1R6fsSh0kvw3HCn3t9j7d3tfQCkE/edit
Sorry for the question, I'm not an iOs developer =) that's why I could miss something. Maybe I missed something related to SPM.
Thank you in advance!
We run into the same issue, but we are using static framework in our project.
Make sure to follow the installation guide, there is a "Run Script" phase to add in Xcode project to copy the resources bundle into the app: https://github.com/icerockdev/moko-resources#iosmacos-static-kotlin-frameworks-support
@andreabusi thank you for your response. I have a question regarding the way you handle your repositories. Do you have ios and android apps in different repos?
Also, as I got from the configuration readme of the lib, it provides the ability to use dynamic frameworks and it's not mandatory to make it static to be able to use the lib.
ty in advance
@andreabusi thank you for your response. I have a question regarding the way you handle your repositories. Do you have ios and android apps in different repos?
For this specific project, we decided to use a single repository with both iOS and Android app. This is good in order to avoid submodules to manage the shared KMM project.
Also, as I got from the configuration readme of the lib, it provides the ability to use dynamic frameworks and it's not mandatory to make it static to be able to use the lib.
Yes, use the dynamic framework if you don't have any specific need. We had to use static framework due to some external dependencies incompatibility (Firebase).
thank you all for your comments - @andreabusi , if it helps for anybody, I added this and it solved.