# How a Kotlin Multiplatform library is published?

DevFeed: [How a Kotlin Multiplatform library is published?](<https://devfeed.tech/articles/how-a-kotlin-multiplatform-library-is-published-22982.md>)

Original publisher: [Read original article](<https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-discovering-the-library-structure-3oeo>)

Author: Ekaterina Petrova

Published: 2021-03-25T12:40:27Z

Content type: tutorial

Language: en

Sources: [Kotlin](<https://devfeed.tech/sources/kotlin-2.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Library](<https://devfeed.tech/topics/library.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Maven](<https://devfeed.tech/topics/maven.md>), [Cross-Compilation](<https://devfeed.tech/topics/cross-compilation.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [macOS](<https://devfeed.tech/topics/macos.md>)

Tags: [coding](<https://devfeed.tech/tags/coding.md>), [community](<https://devfeed.tech/tags/community.md>), [compilation](<https://devfeed.tech/tags/compilation.md>), [cross-compilation](<https://devfeed.tech/tags/cross-compilation.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [inclusive](<https://devfeed.tech/tags/inclusive.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [library](<https://devfeed.tech/tags/library.md>), [macos](<https://devfeed.tech/tags/macos.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [native](<https://devfeed.tech/tags/native.md>), [software](<https://devfeed.tech/tags/software.md>)

## AI overview

This tutorial explains how Kotlin Multiplatform libraries are published. It describes the multiple artifacts, common and platform-specific source sets, Maven project coordinates, and platform constraints such as Kotlin/Native cross-compilation for iOS and macOS.

## Source excerpt

In the first part of the series, we've created our first multiplatform library and published it to the local Maven. Before going public, let's discover published artifacts to get an understanding of the multiplatform publishing format. TL;DR: The Kotlin Gradle plugin creates and configures your library publications automatically, so you don't need to know the details of the publication scheme to successfully deliver your library. But if you are curious, let's discuss it a little! Discovering your library structure If you have published regular platform (for example, android) libraries before, you may notice that the publishing format of a multiplatform library differs quite a lot. There are multiple artifacts for one version of your library, their content format is different (.jar vs .klib), and the number of source sets doesn't match the number of result artifacts. This is because ordinary publishing is not enough for a multiplatform library. Multiplatform libraries have more complex structures compared to normal ones, so the publication is less trivial as well. Here are key differences to keep in mind: Multiplatform libraries consist of multiple parts: common parts with expects declarations and platform-specific parts with actual implementations. Platform-specific code may still be shared across similar platforms (e.g. in a source set shared between the iOS device and simulator, or shared code for all desktop platforms). There should be the ability to publish all those parts from a multiple host because of Kotlin/Native cross-compilation limitations. For example, the artifacts for iOS or macOS can be built only on Mac-OS. Considering all that complexity, adding the ordinary multiplatform dependency requires just a single line of code in your the build.gradle file: dependencies { implementation("io.github.katerinapetrova:mpp-sample-lib:1.0.0") } So how does this magic work? Maven doesn't operate with targets, source sets, and compilations. It operates only with pro