yshrsmz / kgql

GraphQL Document wrapper generator for Kotlin Multiplatform Project and Android
Apache License 2.0
57 stars 2 forks source link

Kotlin Multiplatform build Issue #25

Closed RameshKanuganti closed 5 years ago

RameshKanuganti commented 5 years ago

Hi

While I'm trying to integrate the kgql in Kotlin MPP, it's throwing the following error

No signature of method: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation.outputKinds() is applicable for argument types: (String) values: [FRAMEWORK]

Following is my Shared-Module build.gradle file

apply plugin: "kotlin-multiplatform"
apply plugin: "kotlinx-serialization"
apply plugin: "com.codingfeline.kgql"

kotlin {
    targets {
        fromPreset(presets.jvm, "jvm")

        fromPreset(presets.iosX64, "ios_x86_64")
        fromPreset(presets.iosArm64, "ios_arm64")
        configure([ios_x86_64, ios_arm64]) {
            compilations.main.outputKinds("FRAMEWORK") // Here its throwing error
        }
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation "com.jakewharton.timber:timber-common:$timber_version"
                implementation "io.ktor:ktor-client-core:$ktor_version"
                implementation "io.ktor:ktor-client-json:$ktor_version"
                implementation "org.jetbrains.kotlin:kotlin-stdlib"
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
                implementation "org.kodein.di:kodein-di-core:$kodein_version"
                implementation "org.kodein.di:kodein-di-erased:$kodein_version"
                compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.11.1"
            }
        }
        jvmMain {
            dependencies {
                implementation "com.jakewharton.timber:timber-jdk:$timber_version"
                implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
                implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
                implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.9.1")
                compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.11.1"
            }
        }
        iosMain {
            dependencies {
                implementation "com.jakewharton.timber:timberNative:$timber_version"
                implementation "io.ktor:ktor-client-core-ios:$ktor_version"
                implementation "io.ktor:ktor-client-ios:$ktor_version"
                implementation "io.ktor:ktor-client-json-ios:$ktor_version"
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
                compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.11.1"

            }
        }
        configure([ios_x86_64Main, ios_arm64Main]) {
            dependsOn iosMain
        }
    }
}

configurations {
    compileClasspath
}

task packForXCode(type: Sync) {
    final File frameworkDir = new File(buildDir, "xcode-frameworks")

    final String configuration = project.findProperty("CONFIGURATION")?.toUpperCase() ?: "DEBUG"
    final String arch = project.findProperty("ARCHS") ?: "x86_64"

    dependsOn kotlin.targets."ios_${arch}".compilations.main.linkTaskName("FRAMEWORK", configuration)

    from { kotlin.targets."ios_${arch}".compilations.main.getBinary("FRAMEWORK", configuration).parentFile }
    into frameworkDir
}

tasks.build.dependsOn packForXCode

// Can i have a link/example of working kgql with graphql on kotlin MPP

yshrsmz commented 5 years ago

No signature of method: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation.outputKinds() is applicable for argument types: (String) values: [FRAMEWORK]

This is not kgql error, but your configuration. Check out the document here https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries

Can i have a link/example of working kgql with graphql on kotlin MPP

Sorry there is no example right now. README is the only source. I have one outdated repository though.