Skip to content

Commit eada9bb

Browse files
committed
[configuration-cache] read xcode version during task execution instead of configuration phase
1 parent 1be42b3 commit eada9bb

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

plugin/src/main/kotlin/io/github/ttypic/swiftklib/gradle/task/CompileSwiftTask.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ abstract class CompileSwiftTask @Inject constructor(
5555

5656
prepareBuildDirectory()
5757
createPackageSwift()
58-
val (libPath, headerPath) = buildSwift()
58+
val xcodeMajorVersion = readXcodeMajorVersion()
59+
val (libPath, headerPath) = buildSwift(xcodeMajorVersion)
5960

6061
createDefFile(
6162
libPath = libPath,
6263
headerPath = headerPath,
6364
packageName = packageName,
65+
xcodeVersion = xcodeMajorVersion,
6466
)
6567
}
6668

@@ -69,10 +71,6 @@ abstract class CompileSwiftTask @Inject constructor(
6971
private val minTvos get() = minTvosProperty.getOrElse(13)
7072
private val minWatchos get() = minWatchosProperty.getOrElse(8)
7173

72-
private val xcodeVersion: Int by lazy {
73-
readXcodeMajorVersion()
74-
}
75-
7674
/**
7775
* Creates build directory or cleans up if it already exists
7876
* and copies Swift source files to it
@@ -97,7 +95,7 @@ abstract class CompileSwiftTask @Inject constructor(
9795
.create(createPackageSwiftContents(cinteropName))
9896
}
9997

100-
private fun buildSwift(): SwiftBuildResult {
98+
private fun buildSwift(xcodeVersion: Int): SwiftBuildResult {
10199
val sourceFilePathReplacements = mapOf(
102100
buildDir().absolutePath to pathProperty.get().absolutePath
103101
)
@@ -214,7 +212,7 @@ abstract class CompileSwiftTask @Inject constructor(
214212
* Note: adds lib-file md5 hash to library in order to automatically
215213
* invalidate connected cinterop task
216214
*/
217-
private fun createDefFile(libPath: File, headerPath: File, packageName: String) {
215+
private fun createDefFile(libPath: File, headerPath: File, packageName: String, xcodeVersion: Int) {
218216
val xcodePath = readXcodePath()
219217

220218
val linkerPlatformVersion =

0 commit comments

Comments
 (0)