英文:
Cannot find String.format in Kotlin Multiplatform shared module
问题
我觉得这很奇怪。我正在尝试在我的Kotlin Multiplatform设置的shared模块代码中使用String.format。它找不到format函数,并且在Android Studio中没有自动完成。但在androidMain模块中正常工作。
英文:
I find this weird. I am trying to use String.format in my shared module code in a Kotlin Multiplatform setup. It cannot find the format function and does not autocomplete in Android Studio. But it is working fine in the androidMain module.
答案1
得分: 1
"format" 需要平台本地化信息。KMP 不直接支持本地化。该函数适用于 JVM(或 Android)代码。您需要进行某种期望/实际操作,或找到某种可以执行此操作的库,尽管我目前不知道有哪些库可用。
英文:
IIRC, format needs platform localization info. KMP does not directly support localization. That function is available for the JVM (or Android) code.
You'll need to do some kind of expect/actual, or find some kind of library that does this, although I don't know of any off-hand.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论