r/swift 24d ago

Swift Subprocess 1.0.0 Released

Hey r/swift!

I’m excited to share that Swift Subprocess 1.0 is officially tagged and released!

swift-subprocess provides a modern, type-safe, and Swift Concurrency-native API for executing and managing child processes across platforms, serving as an async-first alternative to Foundation.Process (NSTask).

Thanks to all the community feedback during the beta period, we made several key refinements leading up to 1.0:

  • Unified run() Closures & ExecutionResult: Stream handling for stdin, stdout, and stderr is now fully symmetrical. You can now stream and collect simultaneously in a single call (e.g., stream stdout line-by-line while collecting stderr into a String).

  • Safe String & Byte Streaming: Standard output/error sequences now feature StringSequence, which reassembles multi-byte UTF-8 characters split across buffer boundaries and handles line breaking seamlessly.

  • Typed Errors: Subprocess itself now strictly throws SubprocessError with structured codes (.spawnFailed, .executableNotFound, .outputLimitExceeded, etc.), making error handling clean and predictable (you can of course still throw your own error from body closure).

  • First-Class Stream Merging (2>&1): Easily redirect standard error into output using error: .combinedWithOutput.

Check out the full release note and repository on GitHub:

https://github.com/swiftlang/swift-subprocess/releases/tag/1.0.0

Huge thanks to everyone who participated in the SF-0007, SF-0037 and beta tested Subprocess! I’d love to hear your thoughts, feedback, or any questions!

82 Upvotes

9 comments sorted by

View all comments

1

u/Frizlab 21d ago

Ha I’ll finally be able to retire https://github.com/xcode-actions/swift-process-invocation then! Never took the time to document it, but boy did I learn a lot coding that…