[Gradle, Cocoapods] Added useLibraries() to allow static library pods
#KT-42531 fixed
This commit is contained in:
+10
@@ -64,6 +64,7 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
|
||||
private val defaultPodRepo = "https://github.com/AFNetworking/AFNetworking"
|
||||
private val defaultPodName = "AFNetworking"
|
||||
private val defaultLibraryPodName = "YandexMapKit"
|
||||
private val downloadUrlPodName = "podspecWithFilesExample"
|
||||
private val downloadUrlRepoName = "https://github.com/alozhkin/podspecWithFilesExample/raw/master"
|
||||
private val defaultTarget = "IOS"
|
||||
@@ -729,6 +730,15 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUseLibrariesMode() {
|
||||
with(project) {
|
||||
gradleBuildScript().appendToCocoapodsBlock("useLibraries()")
|
||||
gradleBuildScript().addPod(defaultLibraryPodName)
|
||||
testImport()
|
||||
}
|
||||
}
|
||||
|
||||
// paths
|
||||
|
||||
private fun CompiledProject.url() = externalSources().resolve("url")
|
||||
|
||||
+10
@@ -45,6 +45,16 @@ open class CocoapodsExtension(private val project: Project) {
|
||||
needPodspec = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup cocoapods-generate to produce xcodeproj compatible with static libraries
|
||||
*/
|
||||
fun useLibraries() {
|
||||
useLibraries = true
|
||||
}
|
||||
|
||||
@get:Input
|
||||
internal var useLibraries: Boolean = false
|
||||
|
||||
/**
|
||||
* Configure license of the pod built from this project.
|
||||
*/
|
||||
|
||||
+1
@@ -407,6 +407,7 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||
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.outputFileProvider.get() }
|
||||
it.useLibraries = project.provider { cocoapodsExtension.useLibraries }
|
||||
it.specRepos = project.provider { cocoapodsExtension.specRepos }
|
||||
it.family = family
|
||||
it.pods.set(cocoapodsExtension.pods)
|
||||
|
||||
+4
@@ -352,6 +352,9 @@ open class PodGenTask : DefaultTask() {
|
||||
@get:InputFile
|
||||
internal lateinit var podspec: Provider<File>
|
||||
|
||||
@get:Input
|
||||
internal lateinit var useLibraries: Provider<Boolean>
|
||||
|
||||
@get:Internal
|
||||
lateinit var family: Family
|
||||
|
||||
@@ -379,6 +382,7 @@ open class PodGenTask : DefaultTask() {
|
||||
|
||||
val podGenProcessArgs = listOfNotNull(
|
||||
"pod", "gen",
|
||||
"--use-libraries".takeIf { useLibraries.get() },
|
||||
"--platforms=${family.platformLiteral}",
|
||||
"--gen-directory=${syntheticDir.absolutePath}",
|
||||
localPodspecPaths.takeIf { it.isNotEmpty() }?.joinToString(separator = ",")?.let { "--local-sources=$it" },
|
||||
|
||||
Reference in New Issue
Block a user