Hello guys, I'm looking for a guide to add platfor...
# multiplatform
n
Hello guys, I'm looking for a guide to add platform specific code to KMP but without luck so far. More specifically, is there any guide for adding
macosMain
into KMP project? Thanks for reading!
I'm trying to add
macosMain
but having an issue with dependency
Copy code
macosArm64("macos") {
        binaries {
            executable()
        }
    }

    sourceSets {
        val desktopMain by getting

        val macosMain by getting {
            dependsOn(desktopMain)
        }

        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
        }

        desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
        }
    }
Error gradle sync:
Copy code
Could not resolve all artifacts for configuration ':composeApp:macosCompileKlibraries'.
> Could not resolve org.jetbrains.compose.desktop:desktop:1.6.11.
  Required by:
      project :composeApp > org.jetbrains.compose.desktop:desktop-jvm-macos-arm64:1.6.11
   > No matching variant of org.jetbrains.compose.desktop:desktop:1.6.11 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_arm64', attribute 'org.jetbrains.kotlin.platform.type' with value 'native' but:
       - Variant 'jvmApiElements-published' declares a library for use during compile-time:
e
org.jetbrains.compose.desktop is not built for K/N, desktop is only supported via JVM
n
thanks @ephemient, do you know how can I add platform specific code on macos? or is it not possible atm?
e
macosArm64
cannot be a child of
desktopMain
because desktop dependencies are not available for it
n
@ephemient thanks for the information. however, is there any document that I can looking into? I just need compose as the UI and able to invoke platform specific code.
sorry for the dumb question but I'm super new to KMP
p
Search in GitHub for a project supporting macos target and copy/paste
e
using K/N to target macos is rare. the usual multiplatform target is the JVM one. it should be fine for all desktop platforms
if you just look at the published versions, compose runtime, foundation, ui, etc. are available for K/N macos, just not desktop integration
n
ok, thanks guys. Let me research on it