Any possibility that I can use compose-resources o...
# multiplatform
a
Any possibility that I can use compose-resources only for android & ios but not for windows platform: Here is my gradle:
Copy code
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.kotlinCocoapods)
    alias(libs.plugins.androidLibrary)
    alias(libs.plugins.jetbrainsCompose)
    alias(libs.plugins.compose.compiler)
    id("maven-publish")
}

kotlin {
    //android
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }

    //iOS
    val iosArm64 = iosArm64()
    val iosX64 = iosX64()
    val iosSimulatorArm64 = iosSimulatorArm64()

    // macOS Targets
    val macosX64 = macosX64()
    val macosArm64 = macosArm64()

    val xcFramework = XCFramework("SharedLibrary")
    configure(listOf(iosArm64, iosX64, iosSimulatorArm64, macosX64, macosArm64)) {
        binaries {
            framework {
                isStatic = true
                version = "1.0"
                baseName = "SharedLibrary"
                xcFramework.add(this)
            }
        }
    }

    //Windows
    mingwX64("windows") {
        binaries {
            sharedLib {
                baseName = "SharedLibrary"
            }
        }
    }

    sourceSets {
        //Common
        commonMain.dependencies {
            api(compose.runtime)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }

        //Mac
        iosMain.dependencies {
            api(compose.components.resources)
            api("app.cash.zipline:zipline:1.17.0")
        }
        macosMain.dependencies {
            api(compose.components.resources)
            api("app.cash.zipline:zipline:1.17.0")
        }

        //Android
        androidMain.dependencies {
            api(compose.components.resources)
            api("app.cash.zipline:zipline:1.17.0")
        }

        //Desktop
        val windowsMain by getting {
            dependencies {

            }
        }
    }
}

android {
    namespace = "com.aliazaz.testkmplibrary"
    compileSdk = 34
    defaultConfig {
        minSdk = 22

        aarMetadata {
            minCompileSdk = 22
            minSdk = 22
            targetSdk = 34
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    sourceSets["main"].resources.srcDirs("src/commonMain/composeResources")
    // Ensure that the dependencies are packaged into the .aar file
    packagingOptions {
        resources.excludes.add("META-INF/*")
    }
    publishing {
        singleVariant("release") {
            withSourcesJar()
        }
    }
}

compose.resources {
    publicResClass = true
    packageOfResClass = "com.aliazaz.testkmplibrary"
    generateResClass = auto
}
@jw @mbonnin what you can say?
j
I don't use Compose multiplatform
a
is there any way to share resources between the platforms? Because
moko-resources
is also specific to mobile tech like it is not available for windows platform.
j
No idea. I've never shared resources.
a
As I am also using
zipline
library and it is for android and ios, so, if I am enabling windows platform then I have to define the dependency in both iosMain and androidMain and also the code to tackle things should also be available in both platforms and this will create code redundancy. Like a class ZiplineWrapper is available in both andoridMain and also in iosMain. So, is there any way to deal with this issue, I need your guidance here. Thanks
a
Thanks alot for your response.