From 85908713b14a79c2bf63a269355bf033131b24ba Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Wed, 15 Jul 2020 16:38:49 +0700 Subject: [PATCH] Gradle, CocoaPods: Support pods with dashes in names See https://github.com/JetBrains/kotlin-native/issues/2884 --- .../gradle/targets/native/cocoapods/CocoapodsExtension.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt index 78b66d1ef38..2c4e6a581cb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt @@ -99,7 +99,7 @@ open class CocoapodsExtension(private val project: Project) { * Add a CocoaPods dependency to the pod built from this project. */ @JvmOverloads - fun pod(name: String, version: String? = null, podspec: File? = null, moduleName: String = name.split("/")[0]) { + fun pod(name: String, version: String? = null, podspec: File? = null, moduleName: String = name.asModuleName()) { check(_pods.findByName(name) == null) { "Project already has a CocoaPods dependency with name $name" } _pods.add(CocoapodsDependency(name, version, podspec, moduleName)) } @@ -122,4 +122,10 @@ open class CocoapodsExtension(private val project: Project) { @Input override fun getName(): String = name } + + companion object { + private fun String.asModuleName() = this + .split("/")[0] // Pick the module name from a subspec name. + .replace('-', '_') // Support pods with dashes in names (see https://github.com/JetBrains/kotlin-native/issues/2884). + } } \ No newline at end of file