Hi all,
I currently have this code where i run /usr/bin/say in the terminal, but I stead of doing that, I want to open the sudo nano /private/etc/hosts file and then edit it.
When I change the executableURL variable, to the one that is commented right now, I get this error
Any ideas on how to edit the hosts file through a macOS app?
Button(action: {
let executableURL = URL(fileURLWithPath: "/usr/bin/say")
// let executableURL = URL(fileURLWithPath: "sudo nano /private/etc/hosts")
self.isRunning = true
do {
try Process.run(executableURL,
arguments: ["Hello World"],
terminationHandler: { _ in self.isRunning = false })
} catch{
print(error)
}
}) {
Text("Say")
}