bdeg

    bdeg

    3 years ago
    is there a way to achieve this:
    //For ios target (emulator or real device)
            final def iosTarget = System.getenv("SDK_NAME")?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
            fromPreset(iosTarget, 'ios') {
                compilations.main.outputKinds('FRAMEWORK')
            }
    in the new 1.3.20 mpp plugin ? i tried: def buildForDevice = project.findProperty("device")?.toBoolean() ?: false (buildForDevice) ? iosArm64("ios") : iosX64("ios") targets.compilations["ios"] { compilations.main.outputKinds("framework") binaries { framework { // Disable bitcode embedding for the simulator build. if (!buildForDevice) { embedBitcode("disable") } } } } also:
    def buildForDevice = project.findProperty("device")?.toBoolean() ?: false
        def ios = (buildForDevice) ? iosArm64("ios") : iosX64("ios")
        ios {
            compilations.main.outputKinds("framework")
    
            binaries {
                framework {
                    // Disable bitcode embedding for the simulator build.
                    if (!buildForDevice) {
                        embedBitcode("disable")
                    }
                }
            }
        }
    Dominaezzz

    Dominaezzz

    3 years ago
    How is it not working?
    Does gradle sync casue errors? Or gradle build? or IDE?
    bdeg

    bdeg

    3 years ago
    gradle sync sync failing and ide also failing.
    Dominaezzz

    Dominaezzz

    3 years ago
    Can I see the output of the sync?
    bdeg

    bdeg

    3 years ago
    No signature of method: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.call() is applicable for argument types: (build_1g1pdz1t0dhhtv87rzvo3hutq$_run_closure3$_closure10) values: [build_1g1pdz1t0dhhtv87rzvo3hutq$_run_closure3$_closure10@2df85bc]
    Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), collect()
    Dominaezzz

    Dominaezzz

    3 years ago
    Ah I see.
    Change
    ios {
    to
    ios.apply {
    .
    bdeg

    bdeg

    3 years ago
    does this function work in groovy style build script ?
    Dominaezzz

    Dominaezzz

    3 years ago
    Oops, forgot it's groovy.
    bdeg

    bdeg

    3 years ago
    same, do you have the link to the source code ?
    No signature of method: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.apply() is applicable for argument types: (build_1g1pdz1t0dhhtv87rzvo3hutq$_run_closure3$_closure10) values: [build_1g1pdz1t0dhhtv87rzvo3hutq$_run_closure3$_closure10@1e3f6442]
    Possible solutions: any(), any(groovy.lang.Closure), every(), split(groovy.lang.Closure), every(groovy.lang.Closure)
    Dominaezzz

    Dominaezzz

    3 years ago
    Change
    ios {
    to
    configure([ios]) {
    .
    If you cmd+click on the method, it should show you the source code.
    bdeg

    bdeg

    3 years ago
    configure seems to work, but cmd+click is not working. Can't even do simple compilations configurations with the new 1.3.20...
    Dominaezzz

    Dominaezzz

    3 years ago
    Ah I see, it works on
    *.kts
    .
    bdeg

    bdeg

    3 years ago
    yes im looking at it right now and trying to convert my old code to the new one. For example:
    jvm("backend").compilations {
                main {
                    defaultSourceSet {
                        dependencies {
                            api(kotlin('stdlib-jdk8'))
                            implementation(SpringDependencies.springBootStarter + ":${Configurations.springBootFrameworkVersion}")
                        }
                    }
                }
                test {
                    defaultSourceSet {
                        dependencies {
                            implementation(kotlin('test'))
                            implementation(kotlin('test-junit'))
                            implementation(SpringDependencies.springBootStarterTest + ":${Configurations.springBootFrameworkVersion}")
                        }
                    }
                }
            }
    should work on groovy and kotlin right ? but nope... No signature of method: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget.compilations() is applicable for argument types: (build_1g1pdz1t0dhhtv87rzvo3hutq$_run_closure3$_closure11$_closure18) values: [build_1g1pdz1t0dhhtv87rzvo3hutq$_run_closure3$_closure11$_closure18@5a25c7bc] Possible solutions: getCompilations() strangly if i look at the source code there's a compilation property:https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/kotlinTargets.kt
    Dominaezzz

    Dominaezzz

    3 years ago
    Change
    .compilations
    to ``,
    main
    to
    compilations["main"]
    and
    test
    to
    compilations["test"]
    .
    I recommend moving to
    *.kts
    as the IDE is a bit more helpful with these things in kotlin.
    bdeg

    bdeg

    3 years ago
    it's like the docs are made for kotlin build script only...
    thanks for the help i got it work by using get prefix for kotlin property
    Dominaezzz

    Dominaezzz

    3 years ago
    No problem.
    c

    coletz

    3 years ago
    are you able to compile for ios? I compiled my project for android with kotlin 1.3.20 but is not working on ios... xcode is telling me there is no
    app
    module (while I clearly see it)
    bdeg

    bdeg

    3 years ago
    i'm not yet in the xcode (ios) part, still updating the android, backend part
    russhwolf

    russhwolf

    3 years ago
    You can use
    targetFromPreset()
    to get pretty much the equivalent of the old syntax:
    kotlin {
        final def iosTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
        targetFromPreset(iosTarget, "ios") {
            binaries {
                framework("Shared")
            }
        }
        ...
    }