secretive/Sources/SecretiveUpdater/main.swift

27 lines
856 B
Swift
Raw Permalink Normal View History

2022-02-12 06:52:45 +00:00
import Foundation
class ServiceDelegate: NSObject, NSXPCListenerDelegate {
let exported: UpdaterProtocol
init(exportedObject: UpdaterProtocol) {
self.exported = exportedObject
}
func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool {
newConnection.exportedInterface = NSXPCInterface(with: UpdaterProtocol.self)
newConnection.exportedObject = exported
newConnection.resume()
return true
}
}
let updater = Updater()
let delegate = ServiceDelegate(exportedObject: Updater())
2022-02-17 06:02:57 +00:00
let listener = NSXPCListener(machServiceName: Bundle.main.bundleIdentifier!)
2022-02-12 06:52:45 +00:00
listener.delegate = delegate
listener.resume()
2022-02-17 06:02:57 +00:00
try "Hello world".data(using: .utf8)?.write(to: URL(fileURLWithPath: "/Users/max/Downloads/\(UUID().uuidString).txt"))
RunLoop.current.run()