[Gradle][Cocoapods] Fixed project sync issues when cocoapods are used along with manual framework creation
#KT-50105
This commit is contained in:
committed by
Space
parent
3442631d42
commit
c2a4425784
+2
-1
@@ -942,7 +942,8 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
|
|
||||||
assertEquals(publishPodspecContent, actualPodspecContentWithoutBlankLines)
|
assertEquals(publishPodspecContent, actualPodspecContentWithoutBlankLines)
|
||||||
}
|
}
|
||||||
|
//test that manually created frameworks are not included into cocoapods xcframework
|
||||||
|
project.gradleBuildScript().appendToKotlinBlock("iosX64(\"iOS\") {binaries.framework{}}")
|
||||||
project.testWithWrapper(":podPublishXCFramework")
|
project.testWithWrapper(":podPublishXCFramework")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+46
-45
@@ -66,7 +66,7 @@ internal class CocoapodsBuildDirs(val project: Project) {
|
|||||||
fun externalSources(fileName: String) = externalSources.resolve(fileName)
|
fun externalSources(fileName: String) = externalSources.resolve(fileName)
|
||||||
|
|
||||||
fun fatFramework(buildType: NativeBuildType) =
|
fun fatFramework(buildType: NativeBuildType) =
|
||||||
root.resolve("fat-frameworks/${buildType.toString().toLowerCase()}")
|
root.resolve("fat-frameworks/${buildType.getName()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun String.asValidFrameworkName() = replace('-', '_')
|
internal fun String.asValidFrameworkName() = replace('-', '_')
|
||||||
@@ -241,7 +241,8 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
kotlin.native.cocoapods.paths.frameworks
|
kotlin.native.cocoapods.paths.frameworks
|
||||||
kotlin.native.cocoapods.paths.headers
|
kotlin.native.cocoapods.paths.headers
|
||||||
are not supported and will be ignored since Cocoapods plugin generates all required properties automatically.
|
are not supported and will be ignored since Cocoapods plugin generates all required properties automatically.
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platforms == null || archs == null) {
|
if (platforms == null || archs == null) {
|
||||||
@@ -568,16 +569,17 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
buildType: NativeBuildType
|
buildType: NativeBuildType
|
||||||
): TaskProvider<XCFrameworkTask> =
|
): TaskProvider<XCFrameworkTask> =
|
||||||
with(project) {
|
with(project) {
|
||||||
registerTask("podPublish${buildType.name.toLowerCase().capitalize()}XCFramework") { task ->
|
registerTask(lowerCamelCaseName(POD_FRAMEWORK_PREFIX, "publish", buildType.getName(), "XCFramework")) { task ->
|
||||||
multiplatformExtension.supportedTargets().all { target ->
|
multiplatformExtension.supportedTargets().all { target ->
|
||||||
target.binaries.matching { it.buildType == buildType }.withType(Framework::class.java) { framework ->
|
target.binaries.matching { it.buildType == buildType && it.name.startsWith(POD_FRAMEWORK_PREFIX) }
|
||||||
task.from(framework)
|
.withType(Framework::class.java) { framework ->
|
||||||
}
|
task.from(framework)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
task.outputDir = cocoapodsExtension.publishDir
|
task.outputDir = cocoapodsExtension.publishDir
|
||||||
task.buildType = buildType
|
task.buildType = buildType
|
||||||
task.baseName = project.provider { cocoapodsExtension.frameworkNameInternal }
|
task.baseName = project.provider { cocoapodsExtension.frameworkNameInternal }
|
||||||
task.description = "Produces ${buildType.name.toLowerCase().capitalize()} XCFramework for all requested targets"
|
task.description = "Produces ${buildType.getName().capitalize()} XCFramework for all requested targets"
|
||||||
task.group = TASK_GROUP
|
task.group = TASK_GROUP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,30 +591,31 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
buildType: NativeBuildType
|
buildType: NativeBuildType
|
||||||
): TaskProvider<PodspecTask> =
|
): TaskProvider<PodspecTask> =
|
||||||
with(project) {
|
with(project) {
|
||||||
val task = tasks.register("podSpec${buildType.name.toLowerCase().capitalize()}", PodspecTask::class.java) { task ->
|
val task =
|
||||||
task.description = "Generates podspec for ${buildType.name.toLowerCase().capitalize()} XCFramework publishing"
|
tasks.register(lowerCamelCaseName(POD_FRAMEWORK_PREFIX, "spec", buildType.getName()), PodspecTask::class.java) { task ->
|
||||||
task.outputDir.set(xcFrameworkTask.map { it.outputDir.resolve(it.buildType.getName()) })
|
task.description = "Generates podspec for ${buildType.getName().capitalize()} XCFramework publishing"
|
||||||
task.needPodspec = provider { true }
|
task.outputDir.set(xcFrameworkTask.map { it.outputDir.resolve(it.buildType.getName()) })
|
||||||
task.publishing.set(true)
|
task.needPodspec = provider { true }
|
||||||
task.pods.set(cocoapodsExtension.pods)
|
task.publishing.set(true)
|
||||||
task.specName.set(cocoapodsExtension.name)
|
task.pods.set(cocoapodsExtension.pods)
|
||||||
task.version.set(cocoapodsExtension.version ?: version.toString())
|
task.specName.set(cocoapodsExtension.name)
|
||||||
task.extraSpecAttributes.set(cocoapodsExtension.extraSpecAttributes)
|
task.version.set(cocoapodsExtension.version ?: version.toString())
|
||||||
task.homepage.set(cocoapodsExtension.homepage)
|
task.extraSpecAttributes.set(cocoapodsExtension.extraSpecAttributes)
|
||||||
task.license.set(cocoapodsExtension.license)
|
task.homepage.set(cocoapodsExtension.homepage)
|
||||||
task.authors.set(cocoapodsExtension.authors)
|
task.license.set(cocoapodsExtension.license)
|
||||||
task.summary.set(cocoapodsExtension.summary)
|
task.authors.set(cocoapodsExtension.authors)
|
||||||
task.source.set(cocoapodsExtension.source)
|
task.summary.set(cocoapodsExtension.summary)
|
||||||
task.frameworkName = provider { cocoapodsExtension.frameworkNameInternal }
|
task.source.set(cocoapodsExtension.source)
|
||||||
task.ios = provider { cocoapodsExtension.ios }
|
task.frameworkName = provider { cocoapodsExtension.frameworkNameInternal }
|
||||||
task.osx = provider { cocoapodsExtension.osx }
|
task.ios = provider { cocoapodsExtension.ios }
|
||||||
task.tvos = provider { cocoapodsExtension.tvos }
|
task.osx = provider { cocoapodsExtension.osx }
|
||||||
task.watchos = provider { cocoapodsExtension.watchos }
|
task.tvos = provider { cocoapodsExtension.tvos }
|
||||||
val generateWrapper = project.findProperty(GENERATE_WRAPPER_PROPERTY)?.toString()?.toBoolean() ?: false
|
task.watchos = provider { cocoapodsExtension.watchos }
|
||||||
if (generateWrapper) {
|
val generateWrapper = project.findProperty(GENERATE_WRAPPER_PROPERTY)?.toString()?.toBoolean() ?: false
|
||||||
task.dependsOn(":wrapper")
|
if (generateWrapper) {
|
||||||
|
task.dependsOn(":wrapper")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
xcFrameworkTask.dependsOn(task)
|
xcFrameworkTask.dependsOn(task)
|
||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
@@ -624,29 +627,27 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
) =
|
) =
|
||||||
with(project) {
|
with(project) {
|
||||||
multiplatformExtension.supportedTargets().all { target ->
|
multiplatformExtension.supportedTargets().all { target ->
|
||||||
target.binaries.matching { it.buildType == buildType }.withType(Framework::class.java) { framework ->
|
target.binaries.matching { it.buildType == buildType && it.name.startsWith(POD_FRAMEWORK_PREFIX) }
|
||||||
|
.withType(Framework::class.java) { framework ->
|
||||||
|
|
||||||
val appleTarget = AppleTarget.values().firstOrNull { it.targets.contains(target.konanTarget) } ?: return@withType
|
val appleTarget = AppleTarget.values().firstOrNull { it.targets.contains(target.konanTarget) } ?: return@withType
|
||||||
val fatFrameworkTaskName =
|
val fatFrameworkTaskName =
|
||||||
"pod${buildType.name.toLowerCase().capitalize()}${appleTarget.targetName.capitalize()}FatFramework"
|
lowerCamelCaseName(POD_FRAMEWORK_PREFIX, buildType.getName(), appleTarget.targetName, "FatFramework")
|
||||||
val fatFrameworkTask = if (fatFrameworkTaskName in tasks.names) {
|
val fatFrameworkTask = locateOrRegisterTask<FatFrameworkTask>(fatFrameworkTaskName) { fatTask ->
|
||||||
tasks.named(fatFrameworkTaskName, FatFrameworkTask::class.java)
|
|
||||||
} else {
|
|
||||||
tasks.register(fatFrameworkTaskName, FatFrameworkTask::class.java) { fatTask ->
|
|
||||||
fatTask.baseName = framework.baseName
|
fatTask.baseName = framework.baseName
|
||||||
fatTask.destinationDir = XCFrameworkTask.fatFrameworkDir(this, fatTask.fatFrameworkName, buildType, appleTarget)
|
fatTask.destinationDir =
|
||||||
|
XCFrameworkTask.fatFrameworkDir(this, fatTask.fatFrameworkName, buildType, appleTarget)
|
||||||
fatTask.onlyIf {
|
fatTask.onlyIf {
|
||||||
fatTask.frameworks.size > 1
|
fatTask.frameworks.size > 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fatFrameworkTask.configure {
|
fatFrameworkTask.configure {
|
||||||
it.from(framework)
|
it.from(framework)
|
||||||
}
|
}
|
||||||
|
|
||||||
xcFrameworkTask.dependsOn(fatFrameworkTask)
|
xcFrameworkTask.dependsOn(fatFrameworkTask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user