Created
January 9, 2020 02:04
-
-
Save dilames/5da9d9b79bbdc3fb04063f0f0b210021 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ServiceManagement | |
import SecurityFoundation | |
final class ServiceManagment { | |
enum Error: LocalizedError { | |
case canceledByUser | |
} | |
private init() {} | |
class func JobBless(domain: CFString, | |
executable: String, | |
authorization: SFAuthorization) throws { | |
var error: Unmanaged<CFError>? | |
let result = SMJobBless(domain as CFString, | |
executable as CFString, | |
authorization.authorizationRef(), | |
&error) | |
if !result { throw Error.canceledByUser } | |
if let error = error?.takeRetainedValue() { throw error } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment