Skip to content
This repository was archived by the owner on Oct 19, 2021. It is now read-only.

Commit 94fe4f6

Browse files
committed
Get podspec configs from framework
1 parent dce2c28 commit 94fe4f6

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,13 @@ open class CocoapodsExtension(private val project: Project) {
4848
@Input
4949
var homepage: String? = null
5050

51-
@Internal
52-
internal var frameworkName: String = project.name.asValidFrameworkName()
53-
@Internal
54-
internal var isStatic: Boolean = true
55-
@Internal
5651
internal var frameworkConfiguration: Framework.() -> Unit = {
5752
baseName = project.name.asValidFrameworkName()
5853
isStatic = true
5954
}
6055

6156
internal fun configureFramework(framework: Framework){
6257
frameworkConfiguration(framework)
63-
frameworkName = framework.baseName
64-
isStatic = framework.isStatic
6558
}
6659

6760
@Optional

gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/KotlinCocoapodsPlugin.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
1818
import co.touchlab.kotlin.gradle.tasks.*
1919
import co.touchlab.kotlin.gradle.utils.asValidTaskName
2020
import co.touchlab.kotlin.gradle.utils.lowerCamelCaseName
21-
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
2221
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
2322
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
2423
import org.jetbrains.kotlin.konan.target.HostManager
@@ -163,17 +162,25 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
163162
}
164163

165164
private fun createPodspecGenerationTask(
166-
project: Project,
167-
cocoapodsExtension: CocoapodsExtension
165+
project: Project,
166+
kotlinExtension: KotlinMultiplatformExtension,
167+
cocoapodsExtension: CocoapodsExtension
168168
) {
169+
val firstReleaseFramework = kotlinExtension.supportedTargets()
170+
.single()
171+
.binaries
172+
.getFramework(NativeBuildType.RELEASE)
173+
169174
val dummyFrameworkTask = project.tasks.create("generateDummyFramework", DummyFrameworkTask::class.java) {
170175
it.settings = cocoapodsExtension
176+
it.framework = firstReleaseFramework
171177
}
172178

173179
project.tasks.create("podspec", PodspecTask::class.java) {
174180
it.group = TASK_GROUP
175181
it.description = "Generates a podspec file for CocoaPods import"
176182
it.settings = cocoapodsExtension
183+
it.framework = firstReleaseFramework
177184
it.dependsOn(dummyFrameworkTask)
178185
val generateWrapper = project.findProperty(GENERATE_WRAPPER_PROPERTY)?.toString()?.toBoolean() ?: false
179186
if (generateWrapper) {
@@ -258,7 +265,7 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
258265
afterEvaluate {
259266
createDefaultFrameworks(kotlinExtension, cocoapodsExtension)
260267
createSyncTask(project, kotlinExtension)
261-
createPodspecGenerationTask(project, cocoapodsExtension)
268+
createPodspecGenerationTask(project, kotlinExtension, cocoapodsExtension)
262269
createInterops(project, kotlinExtension, cocoapodsExtension)
263270
}
264271
}

gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/tasks/CocoapodsTasks.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import co.touchlab.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companio
1818
import co.touchlab.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companion.SYNC_TASK_NAME
1919
import co.touchlab.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
2020
import co.touchlab.kotlin.gradle.plugin.cocoapods.cocoapodsBuildDirs
21+
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
2122
import java.io.File
2223

2324
/**
@@ -32,11 +33,14 @@ open class PodspecTask : DefaultTask() {
3233
val outputFile: File = project.projectDir.resolve("$specName.podspec")
3334

3435
@Input
35-
val frameworkNameProvider: Provider<String> = project.provider { settings.frameworkName }
36+
val frameworkNameProvider: Provider<String> = project.provider { framework.baseName}
3637

3738
@get:Nested
3839
internal lateinit var settings: CocoapodsExtension
3940

41+
@get:Nested
42+
internal lateinit var framework: Framework
43+
4044
// TODO: Handle Framework name customization - rename the framework during sync process.
4145
@TaskAction
4246
fun generate() {
@@ -71,7 +75,7 @@ open class PodspecTask : DefaultTask() {
7175
| spec.license = '${settings.license.orEmpty()}'
7276
| spec.summary = '${settings.summary.orEmpty()}'
7377
|
74-
|${if(settings.isStatic){" spec.static_framework = true"}else{""}}
78+
|${if(framework.isStatic){" spec.static_framework = true"}else{""}}
7579
| spec.vendored_frameworks = "$frameworkDir/${frameworkNameProvider.get()}.framework"
7680
| spec.libraries = "c++"
7781
| spec.module_name = "#{spec.name}_umbrella"
@@ -137,11 +141,14 @@ open class DummyFrameworkTask : DefaultTask() {
137141
val destinationDir = project.cocoapodsBuildDirs.framework
138142

139143
@Input
140-
val frameworkNameProvider: Provider<String> = project.provider { settings.frameworkName }
144+
val frameworkNameProvider: Provider<String> = project.provider { framework.baseName }
141145

142146
@get:Nested
143147
internal lateinit var settings: CocoapodsExtension
144148

149+
@get:Nested
150+
internal lateinit var framework: Framework
151+
145152
private val frameworkDir: File
146153
get() = destinationDir.resolve("${frameworkNameProvider.get()}.framework")
147154

0 commit comments

Comments
 (0)