When I use moko-resource in ios side ```LocalizedS...
# moko
a
When I use moko-resource in ios side
Copy code
LocalizedStringKey(MR.strings().welcome_back.resourceId)
it returns the string id instead of the real value, although it works fine on Android side and I have the string value in the used language, what would be the problem?
v
On iOS you are not supposed to use
resourceId
. This would just return the bundle identifier. You should be using
MR.strings().welcome_back.desc().localized()
a
Thank you, it works now! But I used
resourceId
within SwiftUi code as described here, am I misunderstood something?
v
Can’t comment on this as I’m not really knowledgable on the intricacies of SwiftUI.
a
you should use
bundle
that contained in
StringResource
. string with
resourceId
contained in custom bundle inside framework, not in main app bundle
a
I’m newbie to the KMM so I didn’t get what you mean
a
just call
MR.strings().welcome_back.desc().localized()
🙂 i try to describe ios specific details with https://developer.apple.com/documentation/foundation/bundle and https://developer.apple.com/documentation/foundation/nsbundle/1417694-localizedstringforkey?language=objc but for usage you should just call
localized
a
Good to see apple documentation for the first time 😃
a
also you can use:
Copy code
let resource = MR.strings().email
Text(
    LocalizedStringKey(resource.resourceId),
    bundle: resource.bundle
)
with swiftui