Is there any example of iOS library publishing tha...
# kotlin-native
l
Is there any example of iOS library publishing that uses Gradle Kotlin DSL, and targets at least
iosX64
and
iosArm64
?
Since that Gist I added mpp tests support but I still use that
l
Thank you! A few questions: - Since I'm not using third party libs, I can omit everything referencing Carthage? - Do you put your sources in
iosMain
? - The IDE recognizes everything properly? - Would it work if I added a macOS target where the API is shared across these platforms?
r
- Yes, same for the cinterops and all of that - Yes - Yes - No idea
I use the
iosSimMain
->
iosMain
symlink because there is no “common but iOS” sourceSet type yet, not sure how that will change in the future.
l
So the default
iosArm64
target looks for sources into
iosMain
?
r
Yes that’s what I do because I consider it to be the “actual platform”. If you want to target arm32 (and I guess you want for a lib?) you could define something like
iosOldAsFuck
in the Gradle file and just put another simlink
👍🏽 1
m
Or instead of symlink add to each target
Copy code
sourceSets["${targetName}Main"].apply {
        kotlin.srcDir("src/iosMain/kotlin")
    }
👍🏽 1
✔️ 1
r
I guess that works too! My build file is already bloated anyway
l
Oh, nice suggestion @msink! I prefer that one because it works with copy pasting, is transparent in config, and works on all filesystems.
Thank you very much for the info and the gists, Gael!
I tried your approach @msink but Android Studio doesn't seem to like it much. I got this warning after Gradle sync:
00:01 Duplicate content roots detected: Path [/Users/louiscad/Documents/GitHub/Splitties/modules/preferences/src/iosMain/kotlin] of module [preferences_iosArm32Main] was removed from modules [preferences_iosArm32Test, preferences_iosArm64Main, preferences_iosArm64Test, preferences_iosX64Main, preferences_iosX64Test]
I call this function from the
kotlin
lambda in `build.gradle.kts`:
Copy code
fun KotlinMultiplatformExtension.setupIosSourceSets() {
    sourceSets.matching { it.name.startsWith("ios", ignoreCase = true) }.all {
        kotlin.srcDir("src/iosMain/kotlin")
    }
}
After that, when I add an actual declaration to the
iosMain
directory, it removes the error for missing actual for
iosArm32
, but keeps the error for
iosX64
and
iosArm64
. Did you have this problem too, or did you find a workaround?
I'm using symbolic links for now as it works great, but I'm still interested in the sourceSets configuration that doesn't need it, especially as I'd like to share code between iOS and macOS while having IDE support
m
l
Oh, you only have one at a time when developing I see! I should probably do something similar to enable all the targets only when publishing, and use only iosX64 otherwise.
r
Yeah if you build all the targets when in dev you’re going to have a hard time, it already takes ages to build one
👍🏽 1