Gradle, CocoaPods: Use synthetic dir as a working dir for pod gen

'Pod gen' creates an empty folder named 'Pods' in a directory where it
is executed. Earlier, 'pod gen' was executed in a project root
directory, so this `Pods` folder was created in a VCS-controlled
place. This patch fixes this issue by running 'pod gen' in a directory
where the synthetic project is located.
This commit is contained in:
Ilya Matveev
2020-07-15 18:53:55 +07:00
committed by Ilya Matveev
parent 7c3eda31fa
commit a62f65940d
@@ -124,19 +124,19 @@ open class PodGenTask : CocoapodsWithSyntheticTask() {
@TaskAction
fun generate() {
val podspecDir = podspecProvider.get().parentFile
val syntheticDir = project.cocoapodsBuildDirs.synthetic(kotlinNativeTarget).apply { mkdirs() }
val localPodspecPaths = cocoapodsExtension.pods.mapNotNull { it.podspec?.parentFile?.absolutePath }
val podGenProcessArgs = listOfNotNull(
"pod", "gen",
"--platforms=${kotlinNativeTarget.platformLiteral}",
"--gen-directory=${project.cocoapodsBuildDirs.synthetic(kotlinNativeTarget).absolutePath}",
"--gen-directory=${syntheticDir.absolutePath}",
localPodspecPaths.takeIf { it.isNotEmpty() }?.joinToString(separator = ",")?.let { "--local-sources=$it" },
podspecProvider.get().name
podspecProvider.get().absolutePath
)
val podGenProcess = ProcessBuilder(podGenProcessArgs).apply {
directory(podspecDir)
directory(syntheticDir)
}.start()
val podGenRetCode = podGenProcess.waitFor()
val outputText = podGenProcess.inputStream.use { it.reader().readText() }