Hello 👋
We have a kmm project and it was all good until we tried to run it on Xcode 14 😅
iOS is calling a shared api which is a suspend function. It was working fine till now but crashes in Xcode 14 with
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared
Shared kotlin code:
Copy code
open val content: suspend () -> Content =
{ getContent() }
getContent() calls other suspend function to retrieve data from local cache.
iOS code:
Copy code
func getContent() async -> Content {
await sharedGetApi.content.execute() //accessing shared `content` here.
}
extension KotlinSuspendFunction0 {
func execute<T>() async -> T {
do {
let result: T? = try await self.invoke() as? T
if let result = result {
return result
} else {
fatalError("\(T.self) can not be nil")
}
} catch {
fatalError(error.localizedDescription)
}
}
library versions:
coroutines = "1.6.3"
kotlin = "1.6.10"
Any help would be appreciated 🙏
TIA
a
Alex Acosta
09/22/2022, 9:06 PM
Are you using coroutines -mt? This might sound like you are missing to manually activate new memory model.
Alex Acosta
09/22/2022, 9:08 PM
If it is feasible for you, you can upgrade to kotlin 1.7 which enables new mm by default.