https://kotlinlang.org logo
#moko
Title
# moko
b

Bekzod

02/23/2024, 10:24 AM
Hello guys, I moved resources to separate module outside of shared and export(project(":sharedRes")) it in shared gradle. Initially moko resources generated under MR_ as I add more modules to shared gradle such as network, feature.... underline is added after MR___. What could be the root problem
d

Darron Schall

02/23/2024, 4:29 PM
The trailing suffix is happening because Kotlin/Native's Objective-C export will add trailing underscores on name collisions, per https://youtrack.jetbrains.com/issue/KT-50767/Kotlin-Native-Objective-C-Stable-rename-algorithm-for-classes-with-same-name It looks like there are multiple
MR
classes being generated, perhaps in different packages. I don't know enough about your setup to help troubleshoot further -- is this a moko-resources bug producing more than one
MR
erroneously, or maybe is this behaving correctly due to your setup and you're just experiencing the ObjC Export naming convention? That said, it's fine to access your resources in Swift through
MR
or
MR_
or
MR__
in your case depending on which resource you're looking for.
b

Bekzod

02/23/2024, 10:05 PM
Hi @Darron Schall, if resources is inside :shared/commonMain, there is no trailing underscore at all. When I moved it to separate module required setup but this time I implemented dependencies as api not implementation. While keeping plugin in shared. I also
commonMain.dependencies{
implemented(project(":commonMain:resources"))
}
and
framework {
export(project(":commonMain:resources"))
}
//code syntax might be wrong don't pay attention. I don't have code right now))) After rebuilding the project. single trailing underscore added to MR. most interesting part is when I added network_(moko network)_ module which does not have any moko resources configuration. After MR one more trailing underscore added. Previously, similar question asked in this channel. Recommended solution is never use MR in iOS and Android side write expect and actual functions to access it. not sure how to access specific string without resource id without boilerplate manual code. I have already _ underlines already. Imagine if it gets 6-10😅 as I add more modules to shared
if you have same problem, change default name(MR) to something else it might work!K
a

alex009

02/25/2024, 4:10 PM
i agree with solution - just change class name in multimodule to specific names in each module. if you want to export this classes to iOS side
1
or you can change visibility to internal and unexpected MRs will not be exported
🤝 2
3 Views