JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.88k stars 1.15k forks source link

tvos from ios code :shared:tvosArm64Main: Could not resolve org.jetbrains.compose.ui:ui:1.2.2. #2562

Open multiport opened 1 year ago

multiport commented 1 year ago

Hello,

First of all, Thanks for that amazing project, I try to use compose with KMM, I know its not avalaible for tvos but I was planing to use the ios part for tvos :

this is my build.gradle.kts for shared code :

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("org.jetbrains.compose")
}

kotlin {
    android()

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64() ,
        tvosX64(),
        tvosArm64(),
        tvosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
        }
    }

    sourceSets {
        val commonMain by getting{
            dependencies {
                implementation(compose.ui)
                implementation(compose.foundation)
                implementation(compose.material)
                implementation(compose.runtime)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting
        val androidTest by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val tvosX64Main by getting
        val tvosArm64Main by getting
        val tvosSimulatorArm64Main by getting

        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
            tvosX64Main.dependsOn(this)
            tvosArm64Main.dependsOn(this)
            tvosSimulatorArm64Main.dependsOn(this)

        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val tvosX64Test by getting
        val tvosArm64Test by getting
        val tvosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
            tvosX64Test.dependsOn(this)
            tvosArm64Test.dependsOn(this)
            tvosSimulatorArm64Test.dependsOn(this)
        }

    }
}

android {
    namespace = "com.myapp.test"
    compileSdk = 32
    defaultConfig {
        minSdk = 21
        targetSdk = 32
    }
}

As you can see above: the tvos part depends on ios

But i'm getting these error msg :

:shared:tvosArm64Main: Could not resolve org.jetbrains.compose.ui:ui:1.2.2.
Required by:
    project :shared

I dont know how compose works behind but if I use tvos code as an ios one, it should be possible to works isnt it ? If yes , how can I resolve these errors message ? Thanks

igordmn commented 1 year ago

but if I use tvos code as an ios one, it should be possible to works isnt it

No, all dependencies should support tvOS to be able to use it in your project.

Compose can support tvOS in the future, but first we need to bring iOS support to the better state.

multiport commented 1 year ago

but if I use tvos code as an ios one, it should be possible to works isnt it

No, all dependencies should support tvOS to be able to use it in your project.

Compose can support tvOS in the future, but first we need to bring iOS support to the better state.

Thanks for your fast answer, basicaly about what I read the IOS code works directly on TVOS.

So I just plan to make a reponsive IOS app who would execute on tvos too with almost no difference (just plan to manage the key listener and focus change) like an android app on android TV without leanback. Is this not possible currnetly ?

igordmn commented 1 year ago

IOS code works directly on TVOS.

It can work in the Apple tooling ecosystem, but Kotlin Multiplatform doesn't support this. Maybe there are some loopholes, but I am not aware of them. Kotlin Multiplatform requires that every dependency should be compiled against the target platform, even if the code is the same.

multiport commented 1 year ago

So it means I can't create a KMM project with compose for android and ios if i target tvos (with a dedicated UI instaead of compose) ?

igordmn commented 1 year ago

So it means I can't create a KMM project with compose for android and ios

If you don't use any dependencies (libraries I mean), you can. Also, you can, if all of the dependencies support tvOS.

igordmn commented 1 year ago

with compose for android and ios

Just depend on Compose only in androidMain (not in commonMain) and use a native UI in iosMain. Then you be able to depend tvOSMain on iOSMain.

multiport commented 1 year ago

Ok thank you very much.

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.