Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- @objc(myserviceProtocol) protocol myserviceProtocol {
- func ping()
- }
- import Foundation
- class myservice : NSObject, myserviceProtocol {
- func ping() {
- print("ping")
- }
- }
- import Foundation
- class ServiceDelegate : NSObject, NSXPCListenerDelegate {
- func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool {
- newConnection.exportedInterface = NSXPCInterface(with:myserviceProtocol.self)
- let exportedObject = myservice()
- newConnection.exportedObject = exportedObject
- newConnection.resume()
- return true
- }
- }
- // Create the listener and resume it:
- //
- let delegate = ServiceDelegate()
- let listener = NSXPCListener.service()
- listener.delegate = delegate;
- listener.resume()
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>KeepAlive</key>
- <true/>
- <key>Label</key>
- <string>com.demo.myservice</string>
- <key>ProgramArguments</key>
- <array>
- <string>myservice</string>
- </array>
- <key>RunAtLoad</key>
- <true/>
- </dict>
- </plist>
- sudo launchctl debug user/501/com.demo.myservice /Users/olivier/Library/Developer/Xcode/DerivedData/myservice-hbwefcgibyqbajguvblgcmxsnrmd/Build/Products/Debug/myservice.xpc
- Configuration failed: 113: Could not find specified service
- Could not find service "com.demo.myservice" in domain for uid: 501
Add Comment
Please, Sign In to add comment