Skip to content

Commit

Permalink
Fix cocoapods integration (#5128)
Browse files Browse the repository at this point in the history
Use a correct file to configure the cocoapods resources integration
instead of a relative path.

Fixes https://youtrack.jetbrains.com/issue/CMP-4303

## Release Notes
### Fixes - Resources
- _(prerelease fix)_ Fix cocoapods resources integration which leaded to
a lack resources in ios apps
  • Loading branch information
terrakok authored Sep 2, 2024
1 parent 5a06ffe commit aa52511
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 aa52511

Please sign in to comment.