Skip to content

Commit 2d12188

Browse files
committed
Review feedback: use only Foundation instead of stdio functions for writing data back to SwiftPM
1 parent 5df36be commit 2d12188

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/PackagePlugin/Implementation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ extension Plugin {
6868
}
6969
}
7070

71-
// Emit the output from the plugin for SwiftPM to read.
71+
// Encoding the output struct from the plugin for SwiftPM to read.
7272
let encoder = JSONEncoder()
7373
let outputData = try! encoder.encode(output)
74-
fputc(0, stdout)
75-
fputs(String(data: outputData, encoding: .utf8)!, stdout)
76-
fflush(stdout)
74+
75+
// On stdout, write a zero byte followed by the JSON data — this is what libSwiftPM expects to see. Anything before the last zero byte is treated as freeform output from the plugin (such as debug output from `print` statements).
76+
FileHandle.standardOutput.write(Data([0]) + outputData)
7777
}
7878
}
7979

0 commit comments

Comments
 (0)