Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to detect shared ios SourceSet created by KMP plugin #146

Open
yshrsmz opened this issue Apr 24, 2024 Discussed in #145 · 1 comment
Open

Unable to detect shared ios SourceSet created by KMP plugin #146

yshrsmz opened this issue Apr 24, 2024 Discussed in #145 · 1 comment

Comments

@yshrsmz
Copy link
Owner

yshrsmz commented Apr 24, 2024

Discussed in #145

Originally posted by ronjunevaldoz April 23, 2024
In the below config, only the android package contains adMobBannerId

buildkonfig {
    packageName = "com.example.app"
    defaultConfigs {
        buildConfigField(STRING, "oAuthServerId", "test")
    }
    defaultConfigs("dev") {
        buildConfigField(STRING, "oAuthServerId", "test")
    }

    targetConfigs {
        create("android") {
            buildConfigField(STRING, "adMobBannerId", "valueAndroid")
        }

        create("ios") {
            buildConfigField(STRING, "adMobBannerId", "valueIos")
        }
    }
    // flavor is passed as a first argument of targetConfigs
    targetConfigs("dev") {
        create("ios") {
            buildConfigField(STRING, "adMobBannerId", "ca")
        }
        create("android") {
            buildConfigField(STRING, "adMobBannerId", "ca")
        }
    }
}
@yshrsmz
Copy link
Owner Author

yshrsmz commented Apr 24, 2024

afterEvaluate {
    println("afterEvaluate")
    val kmpExt = (this.kotlinExtension as KotlinMultiplatformExtension)
    kmpExt.targets.forEach {target->
        println("-------$target-------")
        target.compilations.filter { !it.name.endsWith(suffix = "Test", ignoreCase = true) }
            .filter { it.platformType == KotlinPlatformType.native }
            .forEach {compilation ->
                println("-------defaultSourceSet-------")
                println(compilation.defaultSourceSet.kotlin.sourceDirectories.forEach { println(it) })
                println("-------allKotlinSourceSets-------")
                println(compilation.allKotlinSourceSets.forEach { a -> a.kotlin.sourceDirectories.forEach { b-> println(b) } })
            }
    }
}

Above snippet prints the output below

afterEvaluate
-------target android (androidJvm)-------
-------target iosArm64 (native)-------
-------defaultSourceSet-------
/Users/yshrsmz/repos/buildkonfig-145/shared/src/iosArm64Main/kotlin
kotlin.Unit
-------allKotlinSourceSets-------
/Users/yshrsmz/repos/buildkonfig-145/shared/src/iosArm64Main/kotlin
kotlin.Unit
-------target iosSimulatorArm64 (native)-------
-------defaultSourceSet-------
/Users/yshrsmz/repos/buildkonfig-145/shared/src/iosSimulatorArm64Main/kotlin
kotlin.Unit
-------allKotlinSourceSets-------
/Users/yshrsmz/repos/buildkonfig-145/shared/src/iosSimulatorArm64Main/kotlin
kotlin.Unit
-------target iosX64 (native)-------
-------defaultSourceSet-------
/Users/yshrsmz/repos/buildkonfig-145/shared/src/iosX64Main/kotlin
kotlin.Unit
-------allKotlinSourceSets-------
/Users/yshrsmz/repos/buildkonfig-145/shared/src/iosX64Main/kotlin
kotlin.Unit
-------target metadata (common)-------

what is this kotlin.Unit ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant