Swift 5.2: Run external program from your SwiftUI application on macOS
Published in
1 min readMay 8, 2020
So, you want to run an external program (e.g., a shell program or script) from your SwiftUI macOS app, and a lot of the posts you’re seeing are from 30 B.C. So here’s something that worked for me on macOS, using Swift 5.2 and SwiftUI whatever the latest version is in 2020.
There are three key steps here:
- Use the
Process
Object to get your owntask
class - Set its properties to prepare for launch
- Run it, and then capture the output of the program so you can, for example, show on your screen
Well, hope that brightened your day.
You know what’s awesome about Apple’s dev docs regarding executableURL
— it’s wonderful, there’s no documentation!
Tagged: swift for the slow