Hello, Earlier I was having one shared module in t...
# multiplatform
r
Hello, Earlier I was having one shared module in the project for sharing between iOS and Android But when I created another shared module. The iOS Header and Protocol files started to have ModuleName appended as Prefix to each class and protocol for iOS Does any one know what's the reasoning behind prefix and how to get rid of it?
m
You can write a GradleTask which makes the adjustments to
__attribute__
...there are also libraries like this one, but I am not sure if they are up to date.
r
Oh did not know about
__attribute__
Let me look into the attribute, I hope this gradle task would be trivial to write BTW do you have any example for this
m
r
Great !! Thanks @Matthias Geisler
a
Do you mean that you have a dependency from the ios exported kmp module to another kmp module?
if that is the case, you can have kmp not generate prefixes by setting the export flag like so
Copy code
val ios = listOf(iosX64(), iosArm64(), iosSimulatorArm64())
configure(ios) {
       binaries {
           framework {
               baseName = "mykmp"
               export(project(":moduleA))
...
you will also need to change the dependency from implementation to api in the dependencies block
👍 1
🙏 1
p
That attribute thing should not be necessary. Properly exporting is the way to go
r
Do you mean that you have a dependency from the ios exported kmp module to another kmp module?
no nothing is exported from iOS
Its regular shared module only
Just in my case, there are two shared modules
p
You can't have different kotlin runtimes. It's always one umbrella Module where the framework is created
r
I am not sure about your framework statement I was able to create two framworks and xcode is also able to detect it as well. Only the Prefix module name is the issue as I mentioned earlier
p
How did you do that?
r
I followed the same pattern of shared module Just repeated the same for second shared module And did the
./gradlew build
after that it was able to generate the framework for both modules
p
Ah, don't do that. You will have two kotlin stdlibs and native runtimes. That will greatly increase size and affect performance. I didn't even think this was possible
Create one iOS umbrella Module, and export both of them as shown above
r
Oh ok, now Understood the above code
It is including other module and exporting is one
p
Well either one includes the other and exports or you have a third umbrella one
r
Hmmm, but I kinda need the second module to be shared with other android app 🤔
p
But how is that an issue?
r
Oh yeah my bad I could share it as
aar
🥲 missed this thing
But that export thing is a great help
Really appreciate it
p
Usually sharing is done through a maven repo
We use gitlab and every project has a maven repo where we publish the builds.
😯 1
r
It is kinda pet project . So did not think of maven repo 🤔. Glad to know this. Will try for this then
p
You can also add it as a git submodule and use includeBuild
r
Have not used submodules yet. It seemed complicated to me at first site. But it was also 3 years ago when I was in sophomore year Hmmm
One more question, with the
export
, the module which I have to export, how can I refer that in xcode? Or would it be available under the module for which framework is generated?
p
It will be in the framework with the name of your framework