Skip to content

Instantly share code, notes, and snippets.

@dilames
Created January 9, 2020 02:04
Show Gist options
  • Save dilames/5da9d9b79bbdc3fb04063f0f0b210021 to your computer and use it in GitHub Desktop.
Save dilames/5da9d9b79bbdc3fb04063f0f0b210021 to your computer and use it in GitHub Desktop.
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