https://kotlinlang.org logo
#ios
Title
# ios
a

Alberto

07/13/2020, 7:38 PM
Getting "Unresolved reference: Class" when building the "compileKotlinIos" step - it seems the "Class" is not resolved for iOS build step, does it need a separate dependency? Code: "operator fun <T : Any> get(apiInterface: Class<T>): LazyComponent<T>" - works fine on a non KMP build.
r

russhwolf

07/13/2020, 8:07 PM
as in,
java.lang.Class
? That only exists on the JVM. Try
KClass
instead.
a

Alberto

07/13/2020, 8:28 PM
Ah got it. I'm getting "Unresolved reference: KClass" as well though? Probably need to add the kotlin reflect library?
r

russhwolf

07/13/2020, 8:29 PM
reflect is also JVM-only, but KClass should be visible without it
a

Alberto

07/13/2020, 8:30 PM
sorry you're right I got a different error - Type argument is not within its bounds: should be subtype of 'Any' - but sounds like it picked the KClass 🙂
interestingly simply switching "Class" with "KClass" builds fine on a non-KMP project. So perhaps it's handled differently on KMP
r

russhwolf

07/13/2020, 8:35 PM
They're different things.
KClass
is the return type of
foo::class
and
Class
is the return type of
foo::class.java
a

Alberto

07/13/2020, 8:40 PM
yeah but I meant that this code builds fine on non-KMP project:
Copy code
import kotlin.reflect.KClass
interface Getter {
    operator fun <T : Any> get(apiInterface: KClass<T>): LazyComponent<T>
}
But fails on KMP project with:
Type argument is not within its bounds: should be subtype of 'Any'
trying to figure out why
r

russhwolf

07/13/2020, 8:41 PM
Oh I see. That is strange
a

Alberto

07/13/2020, 9:05 PM
Nevermind, I had forgot to update in a place "T" to "T : Any" which was causing the issue. Thanks a lot for the support!
👍 1
78 Views