[KT-53174] Add platform version to synthetic generated Podfile.

This commit is contained in:
konstantin.tskhovrebov
2022-07-14 12:39:37 +02:00
committed by Space
parent b26155dd9e
commit 7d6cf449b1
3 changed files with 20 additions and 0 deletions
@@ -240,6 +240,7 @@ class CocoaPodsIT : BaseGradleIT() {
fun testSyntheticProjectPodspecGeneration() {
val gradleProject = transformProjectWithPluginsDsl(cocoapodsSingleKtPod, gradleVersion)
gradleProject.gradleBuildScript().appendToCocoapodsBlock("""
ios.deploymentTarget = "14.1"
pod("SSZipArchive")
pod("AFNetworking", "~> 4.0.1")
pod("Alamofire") {
@@ -251,6 +252,7 @@ class CocoaPodsIT : BaseGradleIT() {
gradleProject.build("podGenIOS", "-Pkotlin.native.cocoapods.generate.wrapper=true") {
assertSuccessful()
val podfileText = gradleProject.projectDir.resolve("build/cocoapods/synthetic/IOS/Podfile").readText().trim()
assertTrue(podfileText.contains("platform :ios, '14.1'"))
assertTrue(podfileText.contains("pod 'SSZipArchive'"))
assertTrue(podfileText.contains("pod 'AFNetworking', '~> 4.0.1'"))
assertTrue(podfileText.contains("pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '5.6.1'"))
@@ -457,6 +457,14 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
}
families += family
val platformSettings = when (family) {
Family.IOS -> cocoapodsExtension.ios
Family.OSX -> cocoapodsExtension.osx
Family.TVOS -> cocoapodsExtension.tvos
Family.WATCHOS -> cocoapodsExtension.watchos
else -> error("Unknown cocoapods platform: $family")
}
project.tasks.register(family.toPodGenTaskName, PodGenTask::class.java) {
it.description = "Сreates a synthetic Xcode project to retrieve CocoaPods dependencies"
it.podspec = podspecTaskProvider.map { task -> task.outputFile }
@@ -464,6 +472,7 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
it.useLibraries = project.provider { cocoapodsExtension.useLibraries }
it.specRepos = project.provider { cocoapodsExtension.specRepos }
it.family = family
it.platformSettings = platformSettings
it.pods.set(cocoapodsExtension.pods)
it.dependsOn(downloadPods)
}
@@ -408,6 +408,9 @@ open class PodGenTask : CocoapodsTask() {
@get:Internal
lateinit var family: Family
@get:Nested
internal lateinit var platformSettings: PodspecPlatformSettings
@get:Nested
internal lateinit var specRepos: Provider<SpecRepos>
@@ -480,6 +483,12 @@ open class PodGenTask : CocoapodsTask() {
if (useLibraries.get().not()) {
appendLine("\tuse_frameworks!")
}
val deploymentTarget = platformSettings.deploymentTarget
if (deploymentTarget != null) {
appendLine("\tplatform :${platformSettings.name}, '$deploymentTarget'")
} else {
appendLine("\tplatform :${platformSettings.name}")
}
pods.get().mapNotNull {
buildString {
append("pod '${it.name}'")