Can't debug Notification Service Extension

Is there a trick to getting debugging working on a Notification Service Extension? I've set breakpoints and none of them are getting hit. I can't even see my print statements in the console. I know something is happening in there, but I'm having to resort to monkeying with the content of the notification to figure out what is happening.


Any ideas are helpful. Thanks!

jared

I haven't gotten this to work yet myself... But the thing to remember is that the service extension is a separate binary. So the trick is really to either run a scheme that runs that binary OR to attach to the process after it is running. this is how we went about debuging the watch extension and today widget extensions

After running the app that contains the extension,

  • Set your breakpoint in the extension
  • Select Debug / Attach to Process by PID or name
  • Enter the name of the extension target
  • Trigger the push notification

    Breakpoints in extensions take forever to trigger. BE PATIENT, eventually your breakpoint will be hit


You will have to do this every time you restart your app via Xcode.


Another tip to be able to disgnose exceptions that occur within your notification content extensions (when these happen the extension content will be all white instead of your custom content):

  • Go to Breakpoint pane in left panel
  • Click PLUS sign in lower part of pane and select "Exception Breakpoint"
  • Accept default settings
  • Select Debug / Attach to Process by PID or name
  • Enter the name of the extension target
  • Trigger the push notification

I am able to place a breakpoint and debug by "stepping" thru the code. However, I am unable to get "print" commands to print to the console. Any pointers on how to print to console?

This is an old question but maybe somebody can find useful the next link where it is explained how to debug the NSE or NCE. In my case I could catch errors and see my print statements. https://medium.com/tiendeo-tech/how-to-debug-ios-extension-d8841f998db4

Can't debug Notification Service Extension
 
 
Q