Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
)
}
Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
)
}
Expand Down Expand Up @@ -118,6 +118,26 @@ private fun getRequestedKonanTargetsByXcode(platform: String, archs: List<String
})
}

// Add tvOS support
platform.startsWith("appletvos") -> {
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) {
Expand All @@ -139,6 +159,7 @@ private fun getRequestedKonanTargetsByXcode(platform: String, archs: List<String
* It's set in project.pbxproj
*
* SyncComposeResourcesForIosTask fails to work with it right now.
* (Note: Despite the name, this task handles all Apple platforms: iOS, tvOS, and macOS)
*
* Gradle attempts to create an output folder for SyncComposeResourcesForIosTask on our behalf,
* so we can't handle an exception when it occurs. Therefore, we make SyncComposeResourcesForIosTask
Expand Down