Skip to content

Commit 7635eea

Browse files
authored
Add SDKROOT when proxying on macOS based on xcrun information (#316)
* Strip newlines from xcrun output
1 parent cdddd4e commit 7635eea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/SwiftlyCore/Platform.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ extension Platform {
210210
newEnv[key] = value
211211
}
212212

213+
#if os(macOS)
214+
// On macOS, we try to set SDKROOT if its empty for tools like clang++ that need it to
215+
// find standard libraries that aren't in the toolchain, like libc++. Here we
216+
// use xcrun to tell us what the default sdk root should be.
217+
if newEnv["SDKROOT"] == nil {
218+
newEnv["SDKROOT"] = (try? await self.runProgramOutput("/usr/bin/xcrun", "--show-sdk-path"))?.replacingOccurrences(of: "\n", with: "")
219+
}
220+
#endif
221+
213222
try self.runProgram([commandToRun] + arguments, env: newEnv)
214223
}
215224

0 commit comments

Comments
 (0)