Skip to content

Commit 92515c9

Browse files
authored
Add SDKROOT when proxying on macOS based on xcrun information (#325)
Add SDKROOT when proxying on macOS based on xcrun information (#316) * Strip newlines from xcrun output
1 parent c219f4d commit 92515c9

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
@@ -183,6 +183,15 @@ extension Platform {
183183
newEnv[key] = value
184184
}
185185

186+
#if os(macOS)
187+
// On macOS, we try to set SDKROOT if its empty for tools like clang++ that need it to
188+
// find standard libraries that aren't in the toolchain, like libc++. Here we
189+
// use xcrun to tell us what the default sdk root should be.
190+
if newEnv["SDKROOT"] == nil {
191+
newEnv["SDKROOT"] = (try? await self.runProgramOutput("/usr/bin/xcrun", "--show-sdk-path"))?.replacingOccurrences(of: "\n", with: "")
192+
}
193+
#endif
194+
186195
try self.runProgram([commandToRun] + arguments, env: newEnv)
187196
}
188197

0 commit comments

Comments
 (0)