what's the most straightforward way to add a .klib...
# kotlin-native
k
what's the most straightforward way to add a .klib artifact to the maven publication created for an iOS target with a framework binary?
k
Curious about your setup. What does the config look like
k
quite simple
Copy code
iosX64("ios") {
        binaries {
            framework()
        }
    }
maven-publish is applied
the only artifact that is publishes is a sources.jar
i've been messing around with it for a couple hours and can't seem to find any way to connect the dots on this
k
I would think you’d need to also add the library binary alongside the framework
Not 100% sure how to do it off hand, but here are the constant options
message has been deleted
k
i tried both staticLib and dynamicLib, which create .a and .dylib, respectively
k
Hmm. If you just remove framework() does it deploy correctly?
k
i see there is a .klib output kind, but didn't see an easy way to link that to an executable
no
i also tried passing the iosMainKlibrary task to
artifact
, but it's not the right type
i don't want to just hardcode the path to the .klib in the build directory because that could break on any plugin change
you would figure this would be pretty simple =/
k
If you just have
iosX64("ios")
without a binary specified, and you’re not publishing with that, then I think you have a different config issue.
I would work on it from that direction. Get the library publishing, then add the framework back
Not the easiest example to follow, but from my firebase lib: https://github.com/touchlab/FirestoreKMP/blob/master/firestore/build.gradle#L77
Copy code
kotlin {

    android {
        publishAllLibraryVariants()
    }

    iosArm64()
    iosX64()
...
k
Copy code
iosX64("ios") {
//        binaries {
//            framework()
//        }
        mavenPublication {
            artifactId = "iosx64"
            artifacts.all { println(file) }
        }
    }
prints /Users/krisw/Dev/act/TelemetryModule/build/libs/TelemetryModule-ios-0.1-sources.jar
k
I would start with one of the several examples of libraries that publish and work from there. I can’t debug your gradle publishing config, but once it’s set up it does work. You need to get that working before also trying to add
framework()
or you’ll have a lot of concurrent issues
k
yeah I looked at stately and didn't see anything obvious I was missing
k
I’ve been mostly copy/pasting that around
Also check that
enableFeaturePreview('GRADLE_METADATA')
is in settings.gradle. It’s the first thing I check now because I forgot it so many times
k
yeah i've got that
the metadata artifact and android artifacts work
oh my lord i've been totally wasting my time. it publishes the artifacts, but
artifacts.all
doesn't include them for some reason so they weren't being printed
k
Ah
k
🤦
k
I’m not a big fan of gradle publish config
k
do you know are both
Copy code
"kotlinMultiplatform", "metadata"
required to publish a multiplatform library?
k
No idea
I just publish the stuff and it works out
k
aight. no reason not to include them both.
thank you as always
👍 1
r
I don’t have a great handle on the difference between them, but can confirm that both
kotlinMultiplatform
and
metadata
are required. Was messing around some with what does and doesn’t need to be included when I was setting up CI for Multiplatform Settings
k
yeah, the multiplatform artifact allows you to specify "groupprojectversion" w/o having to specify each platform
it just tells gradle about the metadata artifact
Copy code
<!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
magic comment
r
Nice. Where’s that comment live?
k
in the multiplatform POM
r
Ah I see it. Thanks!
k
np