Skip to content

Commit

Permalink
Workaround for wrong SDK in build process for Xcode15 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaylor-juul authored and ttypic committed Oct 8, 2023
1 parent 20981ff commit eeaa886
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ open class CompileSwiftTask @Inject constructor(
project.exec {
it.executable = "xcrun"
it.workingDir = swiftBuildDir
it.args = generateBuildArgs()
val extraArgs = if (compileTarget == CompileTarget.iosArm64) {
additionalSysrootArgs()
} else {
emptyList()
}
it.args = generateBuildArgs() + extraArgs
}

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

/** Workaround for bug in toolchain where the sdk path (via `swiftc -sdk` flag) is not propagated to clang. */
private fun additionalSysrootArgs(): List<String> = listOf(
"-Xcc",
"-isysroot",
"-Xcc",
readSdkPath(),
)

private fun readSdkPath(): String {
val stdout = ByteArrayOutputStream()

Expand Down

0 comments on commit eeaa886

Please sign in to comment.