File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,17 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
103
103
104
104
arguments += buildParameters. xcbuildFlags
105
105
106
- let process = Process ( arguments: arguments, outputRedirection: . collect)
106
+ let delegate = createBuildDelegate ( )
107
+ var hasStdout = false
108
+ var stderrBuffer : [ UInt8 ] = [ ]
109
+ let redirection : Process . OutputRedirection = . stream( stdout: { bytes in
110
+ hasStdout = hasStdout || !bytes. isEmpty
111
+ delegate. parse ( bytes: bytes)
112
+ } , stderr: { bytes in
113
+ stderrBuffer. append ( contentsOf: bytes)
114
+ } )
115
+
116
+ let process = Process ( arguments: arguments, outputRedirection: redirection)
107
117
try process. launch ( )
108
118
let result = try process. waitUntilExit ( )
109
119
@@ -115,14 +125,9 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
115
125
throw Diagnostics . fatalError
116
126
}
117
127
118
- let stdout = try result. output. get ( )
119
- if !stdout. isEmpty {
120
- let delegate = createBuildDelegate ( )
121
- delegate. parse ( bytes: stdout)
122
- } else {
123
- let stderr = try result. utf8stderrOutput ( )
124
- if !stderr. isEmpty {
125
- diagnostics. emit ( StringError ( stderr) )
128
+ if !hasStdout {
129
+ if !stderrBuffer. isEmpty {
130
+ diagnostics. emit ( StringError ( String ( decoding: stderrBuffer, as: UTF8 . self) ) )
126
131
} else {
127
132
diagnostics. emit ( StringError ( " Unknown error: stdout and stderr are empty " ) )
128
133
}
You can’t perform that action at this time.
0 commit comments