Hello, I have code like: ```val responseData = Cor...
# kotlin-native
j
Hello, I have code like:
Copy code
val responseData = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).async { ... }
which compiles just fine on Android, but fails to compile on iOS with this error message:
Cannot access 'IO': it is internal in 'Dispatchers'
I've tried to google that, but the only relevant info I found was this: https://github.com/Kotlin/kotlinx.coroutines/issues/3205 according to which it should be implemented. Checked the source code at https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/native/src/Dispatchers.kt ; and indeed, I'd expect the line 22 not to be
internal
: https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/native/src/Dispatchers.kt#L22 - but maybe I'm just missing some import or something? Anybody successfully using Dispatchers.IO in a native project?
j
@Dmitry Stakhov Sure - I've seen that 😉 But I'm getting the error when trying to compile a project using that - so it seems to me that exposing that as the code does, just doesn't work...
I suspect the cause is because of the line 22 - where the 'IO' is internal
If nobody has has a solution here, I'll try to build a local version & come up with a PR if I get it to work for myself.
d
Could you confirm you have the proper import to the extension function?
j
I have
import kotlinx.coroutines.Dispatchers
there, should there be anything else?
[As said, the code compiles as is on Android]
d
Add
import <http://kotlinx.coroutines.IO|kotlinx.coroutines.IO>
j
@Dmitry Stakhov OMG, that was that, thanks so much!
👍 1
Android Studio marks that import like reduntant though, need to dig a bit more why is that; but can at least compile now, which is the main thing 😄