https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
j

Jacob Rhoda

10/12/2023, 4:29 PM
I am piloting 1.9.20-RC and running into some issues. I use the pattern where I
expect
a type in my common code, and use
actual typealias
to make it a native type in my platform code. Specifically, I use it to make an iOS/Android library type into a common type. However, wherever I use this type in common code, the compiler is telling me that I need to opt-in with the
ExperimentalForeignApi
. However, it doesn’t appear that the
kotlin.cinterop
package is available in common code. How do I work around this?
j

Jacob Rhoda

10/12/2023, 5:17 PM
It seems like that kind of breaks the whole idea of expect/actual…but maybe I’m missing something of how the code should be structured.
m

mbonnin

10/12/2023, 5:18 PM
I think the idea is that you shouldn't put platform dependent numbers in expect/actual
j

Jacob Rhoda

10/12/2023, 5:52 PM
Hmm. The thing is that I don’t need to do computation. I just need to an API to pass this value along to the
actual
implementation. For example, I wrote a wrapper around the AppAuth libraries to provide authentication on both platforms with a common API. They don’t really care the
AuthState
implementation, it just needs to pass along a reference to the platform code.