From b58d2d72e730eac9b8f8eafca76a3831c88e257d Mon Sep 17 00:00:00 2001 From: "konstantin.tskhovrebov" Date: Tue, 2 Aug 2022 19:37:17 +0200 Subject: [PATCH] [KT-53340] Cocoapods fix: apply config only to registered frameworks. --- .../native/cocoapods/CocoapodsExtension.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt index 71f5748b177..b9797b2d571 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt @@ -93,13 +93,15 @@ abstract class CocoapodsExtension @Inject constructor(private val project: Proje /** * Configure framework of the pod built from this project. */ - fun framework(configure: Framework.() -> Unit) = configureRegisteredFrameworks(configure) + fun framework(configure: Framework.() -> Unit) { + forAllPodFrameworks(configure) + } /** * Configure framework of the pod built from this project. */ - fun framework(configure: Action) = framework { - configure.execute(this) + fun framework(configure: Action) { + forAllPodFrameworks(configure) } val ios: PodspecPlatformSettings = PodspecPlatformSettings("ios") @@ -238,14 +240,16 @@ abstract class CocoapodsExtension @Inject constructor(private val project: Proje configure.execute(this) } - private fun configureRegisteredFrameworks(configure: Framework.() -> Unit) { + private fun forAllPodFrameworks(action: Action) { project.multiplatformExtension.supportedTargets().all { target -> - target.binaries.withType(Framework::class.java) { framework -> - framework.configure() - if (!framework.isStatic) { - configureLinkingOptions(framework) + target.binaries + .matching { it.name.startsWith(POD_FRAMEWORK_PREFIX) } + .withType(Framework::class.java) { + action.execute(it) + if (!it.isStatic) { + configureLinkingOptions(it) + } } - } } }