Skip to content

Commit

Permalink
[gradle] Use correct file to configure cocoapods resources integratio…
Browse files Browse the repository at this point in the history
…n instead of relative path.
  • Loading branch information
terrakok committed Sep 2, 2024
1 parent 6dbe547 commit 7f508ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}",
Expand Down Expand Up @@ -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")
)
}
}
}

Expand Down

0 comments on commit 7f508ed

Please sign in to comment.