I have the ff gradle ```plugins { id 'org.jetb...
# multiplatform
j
I have the ff gradle
Copy code
plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.71'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.71'
}

repositories {
    jcenter()
    mavenCentral()
}

//apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'
//android {
//    compileSdkVersion 28
//    buildTypes {
//        release {
//            minifyEnabled false
//        }
//    }
//}

kotlin {
    // This is for iPhone emulator
    // Switch here to iosArm64 (or iosArm32) to build library for iPhone device
    targets {
        final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
                          ? presets.iosArm64 : presets.iosX64

        fromPreset(iOSTarget, 'ios') {
            binaries {
                framework("framework")
            }
        }
        fromPreset(presets.jvm, 'android')
    }

    def ktor_version = "1.3.0-rc"
    def serialization_version = "0.14.0"
    def coroutines_version = "1.3.5"
    def klock_version = "1.7.0"

    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
                implementation "io.ktor:ktor-client-core:$ktor_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
                implementation "io.ktor:ktor-client-json:$ktor_version"
                implementation("io.ktor:ktor-client-okhttp:$ktor_version")
                implementation "io.ktor:ktor-client-serialization:$ktor_version"
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
                implementation "com.soywiz.korlibs.klock:klock:$klock_version"
            }
        }
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')
            }
        }
        androidMain {
            dependencies {
                implementation kotlin('stdlib')
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
                implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
            }
        }
        androidTest {
            dependencies {
                implementation kotlin('test')
                implementation kotlin('test-junit')
            }
        }
        iosMain {
            implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
            implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
        }
        iosTest {
            implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
        }
    }
}

// This task attaches native framework built from ios module to Xcode project
// (see iosApp directory). Don't run this task directly,
// Xcode runs this task itself during its build process.
// Before opening the project from iosApp directory in Xcode,
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
task copyFramework {
    def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
    def target = project.findProperty('kotlin.target') ?: 'ios'
    dependsOn kotlin.targets."$target".binaries.getFramework(buildType).linkTask

    doLast {
        def srcFile = kotlin.targets."$target".binaries.getFramework(buildType).outputFile
        def targetDir = getProperty('configuration.build.dir')
        copy {
            from srcFile.parent
            into targetDir
            include 'shared.framework/**'
            include 'shared.framework.dSYM'
        }
    }
}
I also have
enableFeaturePreview("GRADLE_METADATA")
but i couldn't resolve dependencies in my
iosMain
. What am i missing here? Thanks
y
your configuration lacks dependencies block
you are calling implementation right inside the iosMain block
j
Silly mistake! Thanks! @yshrsmz
r
You should also check your library versions. Need all native libraries to be built against 1.3.7x if you’re using that Kotlin version. Coroutines looks right but your ktor and serialization versions are definitely wrong. Not sure on Klock off-hand.