STPrivilegedTask
STPrivilegedTask copied to clipboard
Port to Swift 3
I tried to rewrite the core part of STPrivilegedTask in Swift 3 and it is still working on macOS Sierra:
https://github.com/gui-dos/Guigna/blob/9fdd75ca0337c8081e2a2727960389c7dbf8d694/Legacy/Guigna-Swift/Guigna/GAgent.swift#L42-L80
actually, it is swift 2, isn't it? I have 'init' is unavailable: use 'withMemoryRebound(to:capacity:_)' to temporarily view memory as another layout-compatible type.
this error
I get that too @Maxatma. Did you find a solution?
I've found this: https://github.com/Khala-wan/Slarder. This crash when passing arguments to the script, which is essential for my use case.
@terkelg no, I didn't. I just have found that I no need this. All I was need is put the real path for shell command.
shell("/usr/local/bin/mytool", "somestuff i do with that tool ")
When I used this helper:
//MARK: HELPERS
@discardableResult
func shell(_ args: String...) -> Int32 {
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = args
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
for command-line tool, it works well like that: ` shell( "somestuff i do with needed tool ")
But if I use same for the macOs app, I get some kind of 'permission denied' error. It is fixed if u put the real path for tool.
Hello from 2021) You are welcome swift-5.