kalinjul / kotlin-multiplatform-oidc

Kotlin Multiplatform OpenIDConnect implementation for Android/iOS
https://kalinjul.github.io/kotlin-multiplatform-oidc/
Apache License 2.0
39 stars 15 forks source link

TokenStore/KCrypto/SwiftKlib linker warnings/errors on linkDebugTestIosSimulatorArm64 Task #16

Open dmun opened 6 months ago

dmun commented 6 months ago

Hi there! First of all thank you for the library, setting up authentication was very straightforward using this library.

I've been ignoring these warnings/errors when running my iOS app for while. But now that I need to run my tests using gradle check, the task fails with the following errors.

For context, I'm using your experimental TokenStore and Ktor support. I tried changing versions to match the Kotlin compatibility versions, I tried changing linkerOpts, but without success. I'm pretty new to Kotlin Multiplatform so I might be overlooking something.

I found this issue: Link CocoaPods frameworks with iosTest binary, but not sure if it's still relevant.

...

ld: warning: object file (/Users/me/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/cache/ios_simulator_arm64-gSTATIC-pl/org.jetbrains.skiko:skiko/unspecified/dc1144133edf18f6c19dfb4953d9c7d3dae9394fc65bfbb4250f124bd66549fe/org.jetbrains.skiko:skiko-cache/bin/liborg.jetbrains.skiko:skiko-cache.a(libharfbuzz.hb-subset.o)) was built for newer iOS Simulator version (15.2) than being linked (15.0)
ld: warning: object file (/Users/me/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/cache/ios_simulator_arm64-gSTATIC-pl/org.jetbrains.skiko:skiko/unspecified/dc1144133edf18f6c19dfb4953d9c7d3dae9394fc65bfbb4250f124bd66549fe/org.jetbrains.skiko:skiko-cache/bin/liborg.jetbrains.skiko:skiko-cache.a(libharfbuzz.hb-subset.o)) was built for newer iOS Simulator version (15.2) than being linked (15.0)
ld: warning: object file (/Users/me/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/cache/ios_simulator_arm64-gSTATIC-pl/org.jetbrains.skiko:skiko/unspecified/dc1144133edf18f6c19dfb4953d9c7d3dae9394fc65bfbb4250f124bd66549fe/org.jetbrains.skiko:skiko-cache/bin/liborg.jetbrains.skiko:skiko-cache.a(libharfbuzz.hb-ucd.o)) was built for newer iOS Simulator version (15.2) than being linked (15.0)
ld: warning: object file (/Users/me/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/cache/ios_simulator_arm64-gSTATIC-pl/org.jetbrains.skiko:skiko/unspecified/dc1144133edf18f6c19dfb4953d9c7d3dae9394fc65bfbb4250f124bd66549fe/org.jetbrains.skiko:skiko-cache/bin/liborg.jetbrains.skiko:skiko-cache.a(libharfbuzz.hb-ucd.o)) was built for newer iOS Simulator version (15.2) than being linked (15.0)
ld: warning: object file (/Users/me/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/cache/ios_simulator_arm64-gSTATIC-pl/org.jetbrains.skiko:skiko/unspecified/dc1144133edf18f6c19dfb4953d9c7d3dae9394fc65bfbb4250f124bd66549fe/org.jetbrains.skiko:skiko-cache/bin/liborg.jetbrains.skiko:skiko-cache.a(libharfbuzz.hb-unicode.o)) was built for newer iOS Simulator version (15.2) than being linked (15.0)
ld: warning: object file (/Users/me/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/cache/ios_simulator_arm64-gSTATIC-pl/org.jetbrains.skiko:skiko/unspecified/dc1144133edf18f6c19dfb4953d9c7d3dae9394fc65bfbb4250f124bd66549fe/org.jetbrains.skiko:skiko-cache/bin/liborg.jetbrains.skiko:skiko-cache.a(libharfbuzz.hb-unicode.o)) was built for newer iOS Simulator version (15.2) than being linked (15.0)
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityPacks'
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityPacks'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility56'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility56'
ld: warning: Could not find or use auto-linked library 'swiftObservation'
ld: warning: Could not find or use auto-linked library 'swiftObservation'
Undefined symbols for architecture arm64:
Undefined symbols for architecture arm64:
  "__swift_FORCE_LOAD_$_swiftCompatibility56", referenced from:
  "__swift_FORCE_LOAD_$_swiftCompatibility56", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibility56_$_KCrypto in libio.github.kalinjul.kotlin.multiplatform:oidc-crypto-cinterop-KCrypto-cache.a(KCrypto.swift.o)
      __swift_FORCE_LOAD_$_swiftCompatibility56_$_KCrypto in libio.github.kalinjul.kotlin.multiplatform:oidc-crypto-cinterop-KCrypto-cache.a(KCrypto.swift.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility56_$_KCrypto)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility56_$_KCrypto)
ld: symbol(s) not found for architecture arm64
ld: symbol(s) not found for architecture arm64

> Task :composeApp:linkDebugTestIosSimulatorArm64 FAILED
> Task :composeApp:linkDebugTestIosSimulatorArm64 FAILED
Execution failed for task ':composeApp:linkDebugTestIosSimulatorArm64'.
> Compilation finished with errors

...
kalinjul commented 6 months ago

Hi, thanks for your report.

In my sample-app project next to the library i can run gradle check just fine - without any tests, admittedly. Are you trying to run tests inside src/commonMain or iosMain? Do you have a minimal example project?

I'm using swiftklib to be able to use CryptoKit for the iOS implementation and i set a minimal iOS version of 15, which seems related to the error message.

I'm also using kotlin 1.9.20 in the lib, so that might be related as well.

dmun commented 6 months ago

Hi thank you for your response. I made a small project with the reproducible error.

I have the tests in a separate /shared/src/commonTest module which also seems to launch the linkDebugTestIosSimulatorArm64 for some reason. Not sure if that's intended but I dont think that has something to do with this library.

Running the sample project with the libs.versions.toml properties below works with no errors:

compose-compiler = "1.5.4"
kotlin = "1.9.20"

but with these you get the same error as the original issue:

compose-compiler = "1.5.9"
kotlin = "1.9.22"

So I guess its just a version issue

kalinjul commented 6 months ago

Ok thanks for trying with the older kotlin version! I have a commit in place to update to kotlin 1.9.22, just merged to develop.

Seems that versions have to match. I will test myself and maybe include compatibility notes in the readme. If you want, you can try with the snapshot build that should soon be published to sonatype-snaphots (https://s01.oss.sonatype.org/content/repositories/snapshots/)

Check the ci run here for finish: https://github.com/kalinjul/kotlin-multiplatform-oidc/actions/runs/7977261134

dmun commented 6 months ago

Thank you, but I tried using the 0.8.2-SNAPSHOT on the sample project but it still happens. I think I might have to downgrade my personal own dependencies if these version compatibility docs are still up to date.

kalinjul commented 6 months ago

I don't think they are - using 1.9.22 should be ok.

I still don't know why this is happening, but it seems to pull in the Library Search Path that was used on the github ci at the time of building the library (ld: warning: search path '/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator' not found).

Here's a workaround, you can pass your local search path:

    listOf(
//        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = true
        }

        it.compilations.all {
            kotlinOptions {
                freeCompilerArgs = listOf("-linker-options", "-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator")
            }
        }
    }

With this, you sample builds with 1.9.22 (even using the non-snapshot library). I still have no idea, why this happens with kotlin 1.9.22.

dmun commented 6 months ago

Thank you for the effort! That seems to work for me. The error is fixed and only got some warnings. I'm not sure if they are urgent but I will leave them here:

warning: /Users/runner/work/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/oidc-crypto/build/swiftklib/KCrypto/iosSimulatorArm64/swiftBuild/.build/arm64-apple-macosx/release/ModuleCache/XN47GV1ZJBG0/Foundation-32EX3ABEWCIX8.pcm: No such file or directory
note: while processing /Users/runner/work/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/oidc-crypto/build/swiftklib/KCrypto/iosSimulatorArm64/swiftBuild/.build/arm64-apple-macosx/release/ModuleCache/XN47GV1ZJBG0/Foundation-32EX3ABEWCIX8.pcm
note: Linking a static library that was built with -gmodules, but the module cache was not found.  Redistributable static libraries should never be built with module debugging enabled.  The debug experience will be degraded due to incomplete debug information.
warning: /Users/runner/work/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/oidc-crypto/build/swiftklib/KCrypto/iosSimulatorArm64/swiftBuild/.build/arm64-apple-macosx/release/ModuleCache/XN47GV1ZJBG0/SwiftShims-1NZUW0EWXE1R1.pcm: No such file or directory
note: while processing /Users/runner/work/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/oidc-crypto/build/swiftklib/KCrypto/iosSimulatorArm64/swiftBuild/.build/arm64-apple-macosx/release/ModuleCache/XN47GV1ZJBG0/SwiftShims-1NZUW0EWXE1R1.pcm
warning: /Users/runner/work/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/oidc-crypto/build/swiftklib/KCrypto/iosSimulatorArm64/swiftBuild/.build/arm64-apple-macosx/release/ModuleCache/XN47GV1ZJBG0/_SwiftConcurrencyShims-1NZUW0EWXE1R1.pcm: No such file or directory
note: while processing /Users/runner/work/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/oidc-crypto/build/swiftklib/KCrypto/iosSimulatorArm64/swiftBuild/.build/arm64-apple-macosx/release/ModuleCache/XN47GV1ZJBG0/_SwiftConcurrencyShims-1NZUW0EWXE1R1.pcm

These are from the sample project I provided earlier so you can check them out if you want