https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

rohith

02/03/2022, 6:51 PM
Hi 👋 I’m looking to use BitSet (kotlin.native.BitSet) in my common code. However, Android Studio doesn’t seem to find that package. I was under the impression that it’s included in the stdlib. Do I need to include that dependency explicitly?
m

mkrussel

02/03/2022, 6:56 PM
Are you using it from a native source set and not something like
commonMain
. If you are using it from a shared native source set like
iosMain
you need to enable commonizer for Android Studio to show it.
Copy code
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableCInteropCommonization=true
r

rohith

02/03/2022, 6:58 PM
i am trying to use it in
commonMain
, is that not the way to go?
m

mkrussel

02/03/2022, 7:00 PM
That class is only available in native so you cannot access it from common. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native/-bit-set/ You would need to do some sort of expect/actual declarations to point to the JVM and the native ones on the correct platforms and then common code can use those. Would have been nice if they provided that for you, but there probably is not a JS version.
🙌 1
14 Views