It looks like KMM Plugin v0.3.0 ( <https://kotlinl...
# multiplatform
l
It looks like KMM Plugin v0.3.0 ( https://kotlinlang.org/docs/kmm-plugin-releases.html#release-details ) changed the shared module template a little. While updating a project, I see that
val iosMain by getting
is now replaced by
val iosMain by creating
and using
Copy code
{
  dependsOn(commonMain)
  iosX64Main.dependsOn(this)
  iosArm64Main.dependsOn(this)
  //iosSimulatorArm64Main.dependsOn(this)
}
With
iosX64Main
and
iosArm64Main
being split up to its own
val
. Does this mean I should be adding the dependencies for both (basically just copy them over in both sections)? For some reason, Android studio doesnt want to resolve the correct driver (for sqldelight in my case). See screenshots in the 🧵 .
This is how I 'migrated' the dependencies
On the iOS side, it seems to be unhappy (this is code in the
iosMain
folder)
Using kotlin 1.5.31
rubber duck I think I got it working (by adding new folders,
iosX64Main
and
iosArm64Main
and ignoring any implementation in
iosMain
) but unsure if that's the right way to do this.
With the above the IDE errors went away but when trying to run the project, the compiler complains:
Copy code
> Task :shared:compileKotlinIosX64 FAILED
e: /Users/lalala/TestKMM/shared/src/commonMain/kotlin/com/epicwill/testkmm/Platform.kt: (3, 14): Class 'Platform' has several compatible actual declarations in modules <TestKMM:shared>, <TestKMM:shared>
e: /Users/lalala/TestKMM/shared/src/commonMain/kotlin/com/epicwill/testkmm/Platform.kt: (3, 14): Redeclaration: Platform
e: /Users/lalala/TestKMM/shared/src/commonMain/kotlin/com/epicwill/testkmm/Platform.kt: (3, 22): Constructor of 'Platform' has several compatible actual declarations in modules <TestKMM:shared>, <TestKMM:shared>
e: /Users/lalala/TestKMM/shared/src/commonMain/kotlin/com/epicwill/testkmm/Platform.kt: (4, 9): Property 'platform' has several compatible actual declarations in modules <TestKMM:shared>, <TestKMM:shared>
e: /Users/lalala/TestKMM/shared/src/iosMain/kotlin/com/epicwill/testkmm/Platform.kt: (5, 14): Redeclaration: Platform
e: /Users/lalala/TestKMM/shared/src/iosX64Main/kotlin/com/epicwill/testkmm/Platform.kt: (5, 14): Redeclaration: Platform
I guess
iosMain
isn't smart enought to ignore one of the Platform implementations
Removed the iosMain folder... and now it seems to build & run for the simulator
the content folder of
iosArm64Main
and
iosX64Main
are the same so this feels wrong to me
t
you can change the source folder of both targets to be the same folder (so no need to duplicate the files). this is the most commonly applied workaround AFAIK. The real solution is HMPP, which was improved (and enabled by default in the wizards etc) in 1.6, but have not tried switching (back) to it.
1
a
Hello, @Laurence Muller! It seems like the new module template does not utilize
ios
target shortcut(link). Instead, it does the same thing but manually - declares several ios targets and an intermediate source set being a common between them. This should not stop you from setting the dependencies inside
iosMain
block, and using them inside your code located at
src/iosMain/kotlin...
In your case, you made a step back from the hierarchical Multiplatform approach. Put the code into a single
iosMain
, get rid of your
ios<Arm/X>64Main
s and try again please.
🙏 1
1
l
@Artyom Degtyarev [JB] Thanks! I feel so dumb not trying that initially, but your suggestion works great 🙏 . I think I got thrown off thinking I had to specify the dependencies in their respective architectures.
Copy code
val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            //iosSimulatorArm64Main.dependsOn(this)

            dependencies {
                implementation("com.squareup.sqldelight:native-driver:$sqlDelightVersion")
            }
        }