Skip to content

Commit 3103596

Browse files
committed
Parse stderr from XCBuild only if stdout is empty
1 parent 62c3458 commit 3103596

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Sources/XCBuildSupport/XcodeBuildSystem.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,8 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
104104
arguments += buildParameters.xcbuildFlags
105105

106106
let delegate = createBuildDelegate()
107-
let redirection: Process.OutputRedirection = .stream(stdout: delegate.parse(bytes:), stderr: { bytes in
108-
self.diagnostics.emit(StringError(String(bytes: bytes, encoding: .utf8)!))
109-
})
110-
111-
let process = Process(arguments: arguments, outputRedirection: redirection)
107+
108+
let process = Process(arguments: arguments, outputRedirection: .collect)
112109
try process.launch()
113110
let result = try process.waitUntilExit()
114111

@@ -119,6 +116,14 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
119116
guard result.exitStatus == .terminated(code: 0) else {
120117
throw Diagnostics.fatalError
121118
}
119+
120+
let stdout = try result.output.get()
121+
if !stdout.isEmpty {
122+
try delegate.parse(bytes: result.output.get())
123+
} else {
124+
let stderr = try result.utf8stderrOutput()
125+
self.diagnostics.emit(StringError(stderr))
126+
}
122127
}
123128

124129
func createBuildParametersFile() throws -> AbsolutePath? {

0 commit comments

Comments
 (0)