From 8ac0b9cf5e1a1b1189536c79baaf9d7bb437328b Mon Sep 17 00:00:00 2001 From: Sajid Ali Date: Fri, 16 Jan 2026 11:45:43 +0500 Subject: [PATCH] Add tvOS support in Compose Gradle plugin - Add tvOS target detection (tvos_x64, tvos_arm64, tvos_simulator_arm64) - Update isIosOrMacTarget() to include tvOS targets - Add tvOS platform handling in XCode target detection (appletvos, appletvsimulator) - Update error messages to reference "Apple platforms" instead of just "iOS" --- .../compose/resources/IosResources.kt | 18 +++++++++++---- .../compose/resources/IosResourcesTasks.kt | 23 ++++++++++++++++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt index d96e071380..4eedc9aebd 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt @@ -29,7 +29,7 @@ internal fun Project.configureSyncIosComposeResources( ) { if (ComposeProperties.dontSyncResources(project).get()) { logger.info( - "Compose Multiplatform resource management for iOS is disabled: " + + "Compose Multiplatform resource management for Apple platforms (iOS, tvOS, macOS) is disabled: " + "'${ComposeProperties.SYNC_RESOURCES_PROPERTY}' value is 'false'" ) return @@ -110,9 +110,9 @@ internal fun Project.configureSyncIosComposeResources( it.doFirst { if (specAttributes["resources"] != specAttr) error( """ - |Kotlin.cocoapods.extraSpecAttributes["resources"] is not compatible with Compose Multiplatform's resources management for iOS. + |Kotlin.cocoapods.extraSpecAttributes["resources"] is not compatible with Compose Multiplatform's resources management for Apple platforms. | * Recommended action: remove extraSpecAttributes["resources"] from '$buildFile' and run '$projectPath:podspec' once; - | * Alternative action: turn off Compose Multiplatform's resources management for iOS by adding '${ComposeProperties.SYNC_RESOURCES_PROPERTY}=false' to your gradle.properties; + | * Alternative action: turn off Compose Multiplatform's resources management for Apple platforms by adding '${ComposeProperties.SYNC_RESOURCES_PROPERTY}=false' to your gradle.properties; """.trimMargin() ) } @@ -159,8 +159,18 @@ private fun KotlinNativeTarget.isIosDeviceTarget(): Boolean = private fun KotlinNativeTarget.isIosTarget(): Boolean = isIosSimulatorTarget() || isIosDeviceTarget() +private fun KotlinNativeTarget.isTvosSimulatorTarget(): Boolean = + konanTarget === KonanTarget.TVOS_X64 || konanTarget === KonanTarget.TVOS_SIMULATOR_ARM64 + +private fun KotlinNativeTarget.isTvosDeviceTarget(): Boolean = + konanTarget === KonanTarget.TVOS_ARM64 + +private fun KotlinNativeTarget.isTvosTarget(): Boolean = + isTvosSimulatorTarget() || isTvosDeviceTarget() + private fun KotlinNativeTarget.isMacTarget(): Boolean = konanTarget === KonanTarget.MACOS_X64 || konanTarget === KonanTarget.MACOS_ARM64 + private fun KotlinNativeTarget.isIosOrMacTarget(): Boolean = - isIosTarget() || isMacTarget() + isIosTarget() || isMacTarget() || isTvosTarget() diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResourcesTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResourcesTasks.kt index 62afc07983..79fc36f32d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResourcesTasks.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResourcesTasks.kt @@ -24,7 +24,7 @@ internal abstract class SyncComposeResourcesForIosTask : DefaultTask() { return this.orElse(noProvidedValue).map { if (it == noProvidedValue) { error( - "Could not infer iOS target $attribute. Make sure to build " + + "Could not infer Apple target $attribute. Make sure to build " + "via XCode (directly or via Kotlin Multiplatform Mobile plugin for Android Studio)" ) } @@ -118,6 +118,26 @@ private fun getRequestedKonanTargetsByXcode(platform: String, archs: List { + targets.addAll(archs.map { arch -> + when (arch) { + "arm64", "arm64e" -> KonanTarget.TVOS_ARM64 + else -> error("Unknown tvOS device arch: '$arch'") + } + }) + } + + platform.startsWith("appletvsimulator") -> { + targets.addAll(archs.map { arch -> + when (arch) { + "arm64", "arm64e" -> KonanTarget.TVOS_SIMULATOR_ARM64 + "x86_64" -> KonanTarget.TVOS_X64 + else -> error("Unknown tvOS simulator arch: '$arch'") + } + }) + } + platform.startsWith("macosx") -> { targets.addAll(archs.map { arch -> when (arch) { @@ -139,6 +159,7 @@ private fun getRequestedKonanTargetsByXcode(platform: String, archs: List