question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0.30.0 kotlinx.coroutines does not seem to compile with iOS

See original GitHub issue

I followed the Intellij IDEA File->New Project-> (Kotlin Tab) -> Kotlin (Mobile Android/iOS) generator tool to setup a project for testing a shared codebase between iOS and Android.

The coroutine setup works well for android but for some reason I can’t get a clean build for iOS with the following setup:

kotlin {
    targets {
        // For ARM, preset should be changed to presets.android_arm32 or presets.android_arm64
        fromPreset(presets.android, 'android')
        // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
        fromPreset(presets.iosX64, 'ios')
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
            }
        }
        commonTest {
            dependencies {
        		implementation 'org.jetbrains.kotlin:kotlin-test-common'
        		implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
            }
        }
        androidMain {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
            }
        }
        androidTest {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-test'
                implementation 'org.jetbrains.kotlin:kotlin-test-junit'
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
            }
        }
        iosMain {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
            }
        }
        iosTest {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
            }
        }
    }
}

I get the following exception:

> Task :proj
proj/src/commonMain/kotlin/com/proj/sdk/Sample.kt:3:16: error: unresolved reference: coroutines
import kotlinx.coroutines.*
               ^
proj/src/commonMain/kotlin/com/proj/sdk/Sample.kt:17:5: error: unresolved reference: GlobalScope
    GlobalScope.launch { delay(1000)
    ^
proj/src/commonMain/kotlin/com/proj/sdk/Sample.kt:17:26: error: unresolved reference: delay
    GlobalScope.launch { delay(1000)
                         ^

> Task :proj:compileKotlinIos FAILED

FAILURE: Build failed with an exception.

I do assume I did something wrong, but I i’ve tried using both native+common as dependency for iOS but it does not accept it. Can someone point me towards the right direction?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
armchacommented, Oct 16, 2018

@Syrou try to add enableFeaturePreview('GRADLE_METADATA') in settings.gradle

3reactions
Syroucommented, Oct 15, 2018

Thanks for the reply @wild-lynx As stated below my code snippet I did try with “kotlinx-coroutines-core-native” as dependency as well without any success.

The KotlinConf app uses an older setup than the one specified in https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html, and from my tests only work if you use the -conf2 on the two more important dependencies, and I do not want to go back to something that is not gonna work with the 1.3.0RC/1.3.0

Try cloning the KotlinConf app and bump the versions up to the latest releases and you will notice it does not work anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to add kotlinx-coroutines-reactor to commonMain in ...
I can't import it, and when I try and manually import it, it says unresolved reference. It looks like the package is pure...
Read more >
Migration to coroutines from 0.25.1 to 0.30.2 - Kotlin Discussions
Hi, I'm migrating my server-side code from coroutines 0.25.1 to 0.30.2. ... Using GlobalScope.async does not seem to help (same output).
Read more >
Handling Kotlin Multiplatform Coroutines in Swift — Koru
In Kotlin, concurrency can be handled at the language level. There are some solutions that allow it for Obj-C and Swift, but they...
Read more >
Change log for kotlinx.coroutines
Fixed the Publisher.await functions in kotlinx-coroutines-reactive not ensuring that the Subscriber methods are invoked serially (#3360).
Read more >
Testing Coroutines — Update 1.6.0 | by Ralf Stuckert | Medium
Time control has been moved from the test dispatcher to the TestCoroutineScheduler . From a usage perspective, things do not seem to have ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found