https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Abhishek Dewan

02/16/2021, 6:26 AM
Hi all, I am trying to follow the KampKit project to setup my own and I am running into some issues with Kermit and specifically, the NsLogLogger class. My build gradle is below, when I go to try to use the NsLogLogger class with Kermit it can’t find it. AFAIK there doesn’t seem to be a discernible difference between my gradle and the one in KamptKit. Any ideas would be appreciated. P.S I am able to the iOS library in my external libraries but it just doesn’t find the class 😞
Copy code
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("kotlinx-serialization")
}

kotlin {
    android()
    ios {
        binaries {
            framework {
                baseName = "shared"
                isStatic = false
                export(Deps.kermit)
                transitiveExport = true
            }
        }
    }

    sourceSets {

        all {
            languageSettings.apply {
                useExperimentalAnnotation("kotlin.RequiresOptIn")
                useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
            }
        }

        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation(Deps.Ktor.commonCore)
                implementation(Deps.Ktor.commonJson)
                implementation(Deps.Ktor.commonLogging)
                implementation(Deps.Coroutines.common) {
                    version {
                        strictly(Versions.coroutines)
                    }
                }
                implementation(Deps.multiplatformSettings)
                implementation(Deps.koinCore)
                implementation(Deps.Ktor.commonSerialization)
                implementation(Deps.kotlinxDateTime)
                api(Deps.kermit)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.android.material:material:1.2.1")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation(Deps.Ktor.ios)
            }
        }
        val iosTest by getting
    }
}

android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
    }
}

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}

tasks.getByName("build").dependsOn(packForXcode)
r

russhwolf

02/16/2021, 2:20 PM
Does it build from gradle/command line even if it’s red in the IDE?
a

Abhishek Dewan

02/16/2021, 5:10 PM
Nope doesn’t ! For some reason it just doesn’t see the NSLogLogger class
6 Views