Skip to content

Commit

Permalink
fixup! Support compose resources in native macOS framework in additio…
Browse files Browse the repository at this point in the history
…n to existing executable support
  • Loading branch information
Thomas-Vos committed Nov 29, 2024
1 parent c10d006 commit 8f07e0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private fun Framework.getClassifier(): String {
}

internal fun Framework.getSyncResourcesTaskName() = "sync${getClassifier()}ComposeResourcesForIos"

private fun Framework.isCocoapodsFramework() = name.startsWith("pod")

private fun Framework.getFinalResourcesDir(): Provider<Directory> {
Expand All @@ -125,10 +126,9 @@ private fun Framework.getFinalResourcesDir(): Provider<Directory> {
} else {
providers.environmentVariable("BUILT_PRODUCTS_DIR")
.zip(
providers.environmentVariable("CONTENTS_FOLDER_PATH")
) { builtProductsDir, contentsFolderPath ->
val pathSuffix = if (target.isMacTarget()) "/Resources" else ""
File("$builtProductsDir/$contentsFolderPath$pathSuffix/$IOS_COMPOSE_RESOURCES_ROOT_DIR").canonicalPath
providers.environmentVariable("UNLOCALIZED_RESOURCES_FOLDER_PATH")
) { builtProductsDir, unlocalizedResourcesFolderPath ->
File("$builtProductsDir/$unlocalizedResourcesFolderPath/$IOS_COMPOSE_RESOURCES_ROOT_DIR").canonicalPath
}
.flatMap {
project.objects.directoryProperty().apply { set(File(it)) }
Expand All @@ -142,8 +142,11 @@ private fun KotlinNativeTarget.isIosSimulatorTarget(): Boolean =
private fun KotlinNativeTarget.isIosDeviceTarget(): Boolean =
konanTarget === KonanTarget.IOS_ARM64

private fun KotlinNativeTarget.isIosTarget(): Boolean =
isIosSimulatorTarget() || isIosDeviceTarget()

private fun KotlinNativeTarget.isMacTarget(): Boolean =
konanTarget === KonanTarget.MACOS_X64 || konanTarget === KonanTarget.MACOS_ARM64

private fun KotlinNativeTarget.isIosOrMacTarget(): Boolean =
isIosSimulatorTarget() || isIosDeviceTarget() || isMacTarget()
isIosTarget() || isMacTarget()
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,9 @@ class ResourcesTest : GradlePluginTestBase() {
check.taskSkipped(":prepareComposeResourcesTaskForMacosX64Main")
check.taskSkipped(":generateResourceAccessorsForMacosX64Main")

check.taskSkipped(":syncPodComposeResourcesForMacos")
check.taskSkipped(":syncPodComposeResourcesForIos")
}
gradle(":syncPodComposeResourcesForMacos").checks {
gradle(":syncPodComposeResourcesForIos").checks {
check.taskNoSource(":convertXmlValueResourcesForCommonMain")
check.taskSuccessful(":copyNonXmlValueResourcesForCommonMain")
check.taskSuccessful(":prepareComposeResourcesTaskForCommonMain")
Expand Down

0 comments on commit 8f07e0e

Please sign in to comment.