I get an error when I use a suspend function on Io...
# multiplatform
h
I get an error when I use a suspend function on Ios, I've tried some of the solutions such as adding something to gradle properties and libraries and it still does not work
get this error each time i call a suspend function from my api file in the shared folder
e
Like error says calling Kotlin suspend function is only available in main thread You have two option • wrap suspend function call in
DispatchQueue.main.async
• in your
gradle.properties
add
kotlin.native.binary.objcExportSuspendFunctionLaunchThreadRestriction=none
- this is experimental flag which is turning off the restriction check out my article with more tricky parts of Kotlin <-> Swift interoperability
Also make sure you are using Kotlin
1.7.20+
(since it new memory model is turned on by default) and all possible exceptions declared in
@Throws