Skip to content

Commit 87cbd1e

Browse files
committed
Add SDKROOT when proxying on macOS based on xcrun information
1 parent 5645873 commit 87cbd1e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/SwiftlyCore/Platform.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ extension Platform {
200200
for (key, value) in env {
201201
newEnv[key] = value
202202
}
203+
204+
#if os(macOS)
205+
// On macOS, we try to set SDKROOT if its empty for tools like clang++ that need it to
206+
// find standard libraries that aren't in the toolchain, like libc++. Here we
207+
// use xcrun to tell us what the default sdk root should be.
208+
if newEnv["SDKROOT"] == nil {
209+
newEnv["SDKROOT"] = (try? await self.runProgramOutput("/usr/bin/xcrun", "--show-sdk-path"))
210+
}
211+
#endif
212+
203213
try self.runProgram([command] + arguments, env: newEnv)
204214
}
205215

0 commit comments

Comments
 (0)