I apologize if I'm re-asking the same question as ...
# multiplatform
r
I apologize if I'm re-asking the same question as others, but I've created multiple iOS libraries (using kotlin multiplatform), one that depends upon the other (foundation-data-cache depends upon foundation-data). Then I've created a application that consumes foundation-data-cache. I can build android, desktop (jvm), and wasmJs, but when I attempt to build the iOS app for the simulator, I get the following problem:
Copy code
/Users/ryan/.gradle/caches/modules-2/files-2.1/com.fsryan.foundation.data/foundation-data-cache-iossimulatorarm64/0.0.5/c60e36c7f98128055755c2a8cc08b706d01c396a/foundation-data-cache-iosSimulatorArm64Main-0.0.5 is cached (in /Users/ryan/.konan/kotlin-native-prebuilt-macos-aarch64-2.1.0/klib/cache/ios_simulator_arm64-gSTATIC-pl/com.fsryan.foundation.data:foundation-data-cache/wai8gb5v4e4c.15co47180oxmi/com.fsryan.foundation.data:foundation-data-cache-cache/bin/libcom.fsryan.foundation.data:foundation-data-cache-cache.a), but its dependency isn't: /Users/ryan/.gradle/caches/modules-2/files-2.1/com.fsryan.foundation.data/foundation-data-iossimulatorarm64/0.0.5/b31c720316d75262194102b48c9e82e1184d8054/foundation-data-iosSimulatorArm64Main-0.0.5
I've tried reading through https://slack-chats.kotlinlang.org/t/18860817/trying-to-update-to-kotlin-2-0-0-and-when-i-build-my-ios-app and https://youtrack.jetbrains.com/issue/KT-64086/kotlin-1.9.21-error-klib-is-cached-but-its-dependency-isnt, but I don't really understand the proposed changes. I've deleted my gradle cache (
~/.gradle/caches
) and rebuilt them. I've tried setting
kotlin.native.cacheKind=none
in gradle.properties. I've tried preventing gradle from using the cache, but no matter what I do, I cannot seem to fix this issue. Can someone point me to some guidance on this?
I suppose I'm the only one experiencing this.
Okay. I figured it out by looking at some of the older posts.
here's what I changed.
In my app module, I added some compiler options to the iOS targets:
Copy code
listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "MyLibraryName"
            isStatic = true
        }

        iosTarget.compilerOptions {
            freeCompilerArgs.add("-Xbinary=bundleId=my.library.bundle.id")
            freeCompilerArgs.add("-opt")
        }
    }
That's what worked for me, in case any other devs come across this.