Showing UI and Handling Click events using XPC Service

I want to

  1. build an Xcode Source Code Editor extension
  2. that triggers an XPC service
  3. shows a gui that can handle user interactions

Is it possible in any way ? what are the alternatives to display the UI and allow the user to interact on it ?

Replies

Honestly, I’m not sure how that would pan out.

I have built an Xcode plug-in that performs UI using a CFUserNotification and it worked but the end result was less than stellar. The issue is that the Xcode editor basically gets stuck waiting for the extension to respond to the command it was sent. If that takes more than a second or so, the editor presents its “is still busy” UI. All the time, editing is disabled.

In terms of presenting UI from an XPC service, that’s not completely infeasible but it’s also not a path I generally recommend. The problem is that the main function of an XPC service is expected to call xpc_main. If you set the RunLoopType property to NSRunLoop then xpc_main will start the run loop, which means that AppKit can work, but it’s not the same as calling NSApplicationMain.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"