-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phrase OTA on iOS native project, with KMP moko library #72
Comments
We solve that with our custom handling of fetching resources from the correct bundle. Whenever we tried to fetch from local data we used the moko bundle, and when we tried to use Phrase OTA data, we used the iOS app bundle. |
Hi @BVantur, that's great to hear that both SDKs already work almost out of the box with KMP! Would you mind sharing the snippet that you use to use the correct bundle on iOS if that's possible? I would like to make sure that the KMP support is also properly documented |
Yeah, sure. For moko-based strings that we want to use in a case when there were no Phrase OTA texts present, we used this bundle: But for Phrase OTA texts we needed to use a bundle depending on the language with the URL like this:
In our LocalizationManager we are always trying to read Phrase OTA text first and if it doesn't exist we fall back to a bundle that has strings from the moko library. I hope this comment will help someone who might end up in the same situation. |
We are trying to integrate a Phrase localization service in our KMP project, which is targeting Android and iOS clients. We have managed to do that without a problem so far. We are using the moko-resources library for having shared resources within the shared module of the project and then we are using native-specific code for the setup of Phrase on iOS and Android native projects like it is done when one is using Phrase directly for Android or iOS clients.
Problems for us started when we tried to enable ourselves Over-the-air capability for the iOS project. For Android, this part works without a problem, but on the iOS side, we have problems getting the latest updated strings from the OTA feature visible in the app.
With our moko library, we are using this part in SwiftUI to get the string from resources:
MR.strings().button_label_login.desc.localized()
With this code, we get locally saved text for that phrase key, but when we do some OTA updates for it we don't get the new text from it.
From our investigation, we found out that the problem lies in different bundles being created with the KMP project. There is a bundle of an iOS native project that stores OTA strings from the Phrase, and there is a bundle from Shared code, where we have our shared resources provided for Android and iOS clients. Direct MR.strings() call is using bundle from Shared code.
When we are doing phrase pull that is using the Android way of creating XML files for the moko-resources library, those texts get updated for iOS directly in the build folder of the KMP project under this path:
project-name/shared/build/bin/iosSimulatorArm64/debugFramework/Shared.framework/ProjectName:shared.bundle/Contents/Resources/Base.lproj/Localizable.strings
But your library for Phrase OTA for iOS is adding those strings to the iOS native project bundle.
KMP is getting more and more popular and it would be great if you could either update your existing article on this topic with an explanation of how to integrate the OTA feature with the KMP project or prepare some other documentation for it.
If there is something we are missing with our setup let us know what we need to change to make our OTA integration work in our project.
The text was updated successfully, but these errors were encountered: