Guest User

Untitled

a guest
Jan 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import Foundation
  2.  
  3. @objc(myserviceProtocol) protocol myserviceProtocol {
  4. func ping()
  5. }
  6.  
  7. import Foundation
  8.  
  9. class myservice : NSObject, myserviceProtocol {
  10. func ping() {
  11. print("ping")
  12. }
  13. }
  14.  
  15. import Foundation
  16.  
  17. class ServiceDelegate : NSObject, NSXPCListenerDelegate {
  18. func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool {
  19. newConnection.exportedInterface = NSXPCInterface(with:myserviceProtocol.self)
  20. let exportedObject = myservice()
  21. newConnection.exportedObject = exportedObject
  22. newConnection.resume()
  23. return true
  24. }
  25. }
  26.  
  27. // Create the listener and resume it:
  28. //
  29. let delegate = ServiceDelegate()
  30. let listener = NSXPCListener.service()
  31. listener.delegate = delegate;
  32. listener.resume()
  33.  
  34. <?xml version="1.0" encoding="UTF-8"?>
  35. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  36. <plist version="1.0">
  37. <dict>
  38. <key>KeepAlive</key>
  39. <true/>
  40. <key>Label</key>
  41. <string>com.demo.myservice</string>
  42. <key>ProgramArguments</key>
  43. <array>
  44. <string>myservice</string>
  45. </array>
  46. <key>RunAtLoad</key>
  47. <true/>
  48. </dict>
  49. </plist>
  50.  
  51. sudo launchctl debug user/501/com.demo.myservice /Users/olivier/Library/Developer/Xcode/DerivedData/myservice-hbwefcgibyqbajguvblgcmxsnrmd/Build/Products/Debug/myservice.xpc
  52. Configuration failed: 113: Could not find specified service
  53. Could not find service "com.demo.myservice" in domain for uid: 501
Add Comment
Please, Sign In to add comment