From 7f508ed8e64e5f955afaab3e713a2fc9a5d50082 Mon Sep 17 00:00:00 2001 From: Konstantin Tskhovrebov Date: Mon, 2 Sep 2024 16:01:13 +0200 Subject: [PATCH] [gradle] Use correct file to configure cocoapods resources integration instead of relative path. --- .../jetbrains/compose/resources/IosResources.kt | 6 +++--- .../test/tests/integration/ResourcesTest.kt | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 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 ae31edbafbb..ef6caa15b73 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 @@ -86,8 +86,8 @@ internal fun Project.configureSyncIosComposeResources( plugins.withId(COCOAPODS_PLUGIN_ID) { (kotlinExtension as ExtensionAware).extensions.getByType(CocoapodsExtension::class.java).apply { framework { podFramework -> - val syncDir = podFramework.getFinalResourcesDir().get().asFile.relativeTo(projectDir) - val specAttr = "['${syncDir.path}']" + val syncDir = podFramework.getFinalResourcesDir().get().asFile + val specAttr = "['${syncDir.relativeTo(projectDir).path}']" val specAttributes = extraSpecAttributes val buildFile = project.buildFile val projectPath = project.path @@ -97,7 +97,7 @@ internal fun Project.configureSyncIosComposeResources( if (specAttributes["resources"] != specAttr) error( """ |Kotlin.cocoapods.extraSpecAttributes["resources"] is not compatible with Compose Multiplatform's resources management for iOS. - | * Recommended action: remove extraSpecAttributes["resources"] from '$buildFile' and run '$projectPath:podInstall' once; + | * 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; """.trimMargin() ) diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt index 346daa8756a..703f1444cc6 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt @@ -591,6 +591,14 @@ class ResourcesTest : GradlePluginTestBase() { ) with(TestProject("misc/iosResources", testEnv)) { + gradle(":podspec", "-Pkotlin.native.cocoapods.generate.wrapper=true").checks { + assertEqualTextFiles( + file("iosResources.podspec"), + file("expected/iosResources.podspec") + ) + file("build/compose/cocoapods/compose-resources").checkExists() + } + gradle( ":syncFramework", "-Pkotlin.native.cocoapods.platform=${iosEnv["PLATFORM_NAME"]}", @@ -656,13 +664,6 @@ class ResourcesTest : GradlePluginTestBase() { file("build/compose/cocoapods/compose-resources/composeResources/iosresources.generated.resources/drawable/compose-multiplatform.xml").checkExists() file("build/compose/cocoapods/compose-resources/composeResources/iosresources.generated.resources/drawable/icon.xml").checkExists() } - - gradle(":podspec", "-Pkotlin.native.cocoapods.generate.wrapper=true").checks { - assertEqualTextFiles( - file("iosResources.podspec"), - file("expected/iosResources.podspec") - ) - } } }