InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.93k stars 711 forks source link

No class found for symbol 'kotlin.uuid/Uuid.Companion|null[0]' #1964

Closed allansts closed 3 days ago

allansts commented 1 week ago

Describe the bug When updating Koin from 4.0.0-RC1 to 4.0.0-RC2 when initialising the Koin in iOS this error happens:

Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: kotlin.native.internal.IrLinkageError: Can not get instance of singleton 'Companion': No class found for symbol 'kotlin.uuid/Uuid.Companion|null[0]'
    at 0   iosApp                              0x101a6036b        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 119 
    at 1   iosApp                              0x101a598d3        kfun:kotlin.Error#<init>(kotlin.String?){} + 115 
    at 2   iosApp                              0x101a90c63        kfun:kotlin.native.internal.IrLinkageError#<init>(kotlin.String?){} + 115 
    at 3   iosApp                              0x101a90d1b        kfun:kotlin.native.internal#ThrowIrLinkageError(kotlin.String?){}kotlin.Nothing + 163 
    at 4   iosApp                              0x101c17287        kfun:org.koin.mp#generateId__at__org.koin.mp.KoinPlatformTools(){}kotlin.String + 63 
    at 5   iosApp                              0x101c08d33        kfun:org.koin.core.module.Module#<init>(kotlin.Boolean){} + 231 
    at 6   iosApp                              0x101c16967        kfun:org.koin.dsl#module(kotlin.Boolean;kotlin.Function1<org.koin.core.module.Module,kotlin.Unit>){}org.koin.core.module.Module + 179 
    at 7   iosApp                              0x101c16a6f        kfun:org.koin.dsl#module$default(kotlin.Boolean;kotlin.Function1<org.koin.core.module.Module,kotlin.Unit>;kotlin.Int){}org.koin.core.module.Module + 155 
    at 8   iosApp                              0x100969573        kfun:com.example.kmpnavigation.$init_global#internal + 107 
    at 9   iosApp                              0x101beffeb        CallInitGlobalPossiblyLock + 539 
    at 10  iosApp                              0x1009695f7        kfun:com.example.kmpnavigation#<get-platformModule>(){}org.koin.core.module.Module + 75 
    at 11  iosApp                              0x10096866b        kfun:com.example.kmpnavigation#appModule(){}kotlin.collections.List<org.koin.core.module.Module> + 95 
    at 12  iosApp                              0x1009693cf        kfun:com.example.kmpnavigation.initKoin$lambda$0#internal + 135 
    at 13  iosApp                              0x10096945b        kfun:com.example.kmpnavigation.$initKoin$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 79 
    at 14  iosApp                              0x1009694d3        kfun:com.example.kmpnavigation.$initKoin$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNN>invoke(org.koin.core.KoinApplication){}#internal + 99 
    at 15  iosApp                              0x101b7af6b        kfun:kotlin.Function1#invoke(1:0){}1:1-trampoline + 107 
    at 16  iosApp                              0x101c183f3        kfun:org.koin.core.context.MutableGlobalContext#startKoin(kotlin.Function1<org.koin.core.KoinApplication,kotlin.Unit>){}org.koin.core.KoinApplication + 471 
    at 17  iosApp                              0x101c1ab7b        kfun:org.koin.core.context.KoinContext#startKoin(kotlin.Function1<org.koin.core.KoinApplication,kotlin.Unit>){}org.koin.core.KoinApplication-trampoline + 107 
    at 18  iosApp                              0x101c0136b        kfun:org.koin.core.context#startKoin(kotlin.Function1<org.koin.core.KoinApplication,kotlin.Unit>){}org.koin.core.KoinApplication + 175 
    at 19  iosApp                              0x100969323        kfun:com.example.kmpnavigation#initKoin(){} + 99 
    at 20  iosApp                              0x10098184f        objc2kotlin_kfun:com.example.kmpnavigation#initKoin(){} + 95 
    at 21  iosApp                              0x100965983        $s6iosApp6iOSAppVACycfC + 31 (~/KMP/iosApp/iosApp/iOSApp.swift:8:18)
    at 22  iosApp                              0x100965ea3        $s6iosApp6iOSAppV7SwiftUI0B0AadEPxycfCTW + 11 
    at 23  SwiftUI                             0x1ccbcd6c7        OUTLINED_FUNCTION_0 + 75 
    at 24  iosApp                              0x100965e0b        $s6iosApp6iOSAppV5$mainyyFZ + 39 
    at 25  iosApp                              0x100965eb7        main + 11 (~/KMP/iosApp/iosApp/iOSApp.swift:<unknown>)
    at 26  dyld                                0x1041c1543        0x0 + 4363916611 
    at 27  ???                                 0x103b6e153        0x0 + 4357284179 
    at 28  ???                                 0x226c7fffffffffff 0x0 + 2480498232262655999 

To Reproduce Steps to reproduce the behavior:

  1. Just try to initialise koin with iOS using the 4.0.0-RC2

Expected behavior Initialise normally as the previous version

Koin module and version: koin = "4.0.0-RC2"

koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin" }
koin-compose-viewmodel = { module = "io.insert-koin:koin-compose-viewmodel", version.ref = "koin" }
koin-compose-viewmodel-navigation = { module = "io.insert-koin:koin-compose-viewmodel-navigation", version.ref = "koin" }
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }

Snippet or Sample project to help reproduce Just follow the Koin KMP website sample: https://insert-koin.io/docs/reference/koin-mp/kmp

felix-leyva commented 1 week ago

Same issue here. Might this has something to do, with the switch to kotlin UUID? https://github.com/InsertKoinIO/koin/compare/4.0.0-RC1...4.0.0-RC2#:~:text=import%20kotlin.uuid.ExperimentalUuidApi

maksimpetrovskycorewill commented 1 week ago

I'm facing the same issue.

arnaudgiuliani commented 1 week ago

You need Kotlin 2.0.20, as we are now using KMP UUid feature

Elelan commented 1 week ago

Facing same issue. KMP iOS not building after upgrading koin from 4.0.0-RC1 to 4.0.0-RC2. Kotlin version: 2.0.20 Ksp: 2.0.20-1.0.24

Showing The following message in xcode.

Showing All Messages

Task :composeApp:kspKotlinIosSimulatorArm64 FAILED e: KLIB resolver: Could not find "com.benasher44:uuid" in [/Users/elelan/StudioProjects//-app, /Users/elelan/.konan/klib, /Users/elelan/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.20/klib/common, /Users/elelan/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.20/klib/platform/ios_simulator_arm64]

arnaudgiuliani commented 6 days ago

can you reproduce it easily?

allansts commented 6 days ago

can you reproduce it easily?

@arnaudgiuliani Yep, you can set up the Koin with KMP and use it on iOS. 100% reproducible at least when I tried it with Kotlin 2.0.0

felix-leyva commented 6 days ago

I tried it with Kotlin 2.0.20 and it worked correctly. It seems that it was indeed as you mentioned that the Kotlin UUID was not working with 2.0.0.

arnaudgiuliani commented 5 days ago

@allansts what Kotlin version do you have?

allansts commented 5 days ago

@allansts what Kotlin version do you have?

Kotlin 2.0.0, I will check it with Kotlin 2.0.20

Edited: I retest using Kotlin 2.0.20 and it is working fine so far. Thank you @arnaudgiuliani

Elelan commented 4 days ago

Still reproducible for me. Android is working find. When building iOS only getting the error related to kotlin uuid. Could not find "com.benasher44:uuid" Kotlin 2.0.20 KSP 2.0.20-1.0.25 Koin 4.0.0-RC2

arnaudgiuliani commented 4 days ago

Still reproducible for me. Android is working find. When building iOS only getting the error related to kotlin uuid. Could not find "com.benasher44:uuid" Kotlin 2.0.20 KSP 2.0.20-1.0.25 Koin 4.0.0-RC2

Weird 🤔 I can ping JB team about that. I will try to reproduce it 👍

arnaudgiuliani commented 3 days ago

I removed unused ref to com.benasher44:uuid. Now we are using Kotlin.uuid:

fun KoinPlatformTools.generateId() : String = Uuid.random().toString()

Look if you have a static reference to that kind of UUID object from previous com.benasher44:uuid - commit 23fcf1cbd4a025929f8b75ebad5d5c705bf0a9ba

I could run this on iOS and generate UUID. No problem.

Reopen if you see anything regarding this topic, in next releases 👍