Skip to content

Commit eeaa886

Browse files
davertay-jttypic
authored andcommitted
Workaround for wrong SDK in build process for Xcode15 (#2)
1 parent 20981ff commit eeaa886

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ open class CompileSwiftTask @Inject constructor(
102102
project.exec {
103103
it.executable = "xcrun"
104104
it.workingDir = swiftBuildDir
105-
it.args = generateBuildArgs()
105+
val extraArgs = if (compileTarget == CompileTarget.iosArm64) {
106+
additionalSysrootArgs()
107+
} else {
108+
emptyList()
109+
}
110+
it.args = generateBuildArgs() + extraArgs
106111
}
107112

108113
return SwiftBuildResult(
@@ -134,6 +139,14 @@ open class CompileSwiftTask @Inject constructor(
134139
"${compileTarget.archPrefix()}-apple-${operatingSystem(compileTarget)}.0${compileTarget.simulatorSuffix()}",
135140
)
136141

142+
/** Workaround for bug in toolchain where the sdk path (via `swiftc -sdk` flag) is not propagated to clang. */
143+
private fun additionalSysrootArgs(): List<String> = listOf(
144+
"-Xcc",
145+
"-isysroot",
146+
"-Xcc",
147+
readSdkPath(),
148+
)
149+
137150
private fun readSdkPath(): String {
138151
val stdout = ByteArrayOutputStream()
139152

0 commit comments

Comments
 (0)