https://kotlinlang.org logo
b

bdeg

01/27/2019, 4:45 PM
is there a way to achieve this:
Copy code
//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:
Copy code
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")
                }
            }
        }
    }
d

Dominaezzz

01/27/2019, 4:48 PM
How is it not working?
Does gradle sync casue errors? Or gradle build? or IDE?
b

bdeg

01/27/2019, 4:49 PM
gradle sync sync failing and ide also failing.
d

Dominaezzz

01/27/2019, 4:50 PM
Can I see the output of the sync?
b

bdeg

01/27/2019, 4:50 PM
Copy code
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()
d

Dominaezzz

01/27/2019, 4:51 PM
Ah I see.
Change
ios {
to
ios.apply {
.
b

bdeg

01/27/2019, 4:51 PM
does this function work in groovy style build script ?
d

Dominaezzz

01/27/2019, 4:52 PM
Oops, forgot it's groovy.
b

bdeg

01/27/2019, 4:52 PM
same, do you have the link to the source code ?
Copy 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)
d

Dominaezzz

01/27/2019, 4:55 PM
Change
ios {
to
configure([ios]) {
.
If you cmd+click on the method, it should show you the source code.
b

bdeg

01/27/2019, 4:59 PM
configure seems to work, but cmd+click is not working. Can't even do simple compilations configurations with the new 1.3.20...
d

Dominaezzz

01/27/2019, 5:01 PM
Ah I see, it works on
*.kts
.
b

bdeg

01/27/2019, 5:05 PM
yes im looking at it right now and trying to convert my old code to the new one. For example:
Copy code
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
d

Dominaezzz

01/27/2019, 5:08 PM
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.
b

bdeg

01/27/2019, 5:20 PM
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
d

Dominaezzz

01/27/2019, 5:21 PM
No problem.
c

coletz

01/27/2019, 5:59 PM
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)
b

bdeg

01/27/2019, 6:03 PM
i'm not yet in the xcode (ios) part, still updating the android, backend part
r

russhwolf

01/27/2019, 8:57 PM
You can use
targetFromPreset()
to get pretty much the equivalent of the old syntax:
Copy code
kotlin {
    final def iosTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
    targetFromPreset(iosTarget, "ios") {
        binaries {
            framework("Shared")
        }
    }
    ...
}