STPrivilegedTask icon indicating copy to clipboard operation
STPrivilegedTask copied to clipboard

Port to Swift 3

Open gui-dos opened this issue 8 years ago • 5 comments

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

gui-dos avatar Jul 06 '16 09:07 gui-dos

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

Maxatma avatar Sep 11 '17 00:09 Maxatma

I get that too @Maxatma. Did you find a solution?

terkelg avatar Sep 14 '17 01:09 terkelg

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 avatar Sep 14 '17 23:09 terkelg

@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.

Maxatma avatar Sep 15 '17 02:09 Maxatma

Hello from 2021) You are welcome swift-5.

x13a avatar Jul 22 '21 17:07 x13a