Getting "Unresolved reference: Class" when buildin...
# ios
a
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
as in,
java.lang.Class
? That only exists on the JVM. Try
KClass
instead.
a
Ah got it. I'm getting "Unresolved reference: KClass" as well though? Probably need to add the kotlin reflect library?
r
reflect is also JVM-only, but KClass should be visible without it
a
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
They're different things.
KClass
is the return type of
foo::class
and
Class
is the return type of
foo::class.java
a
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
Oh I see. That is strange
a
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