7

I'm working through this tutorial and it works just fine on a simulator, except I don't understand how the methods are being called. The today view widget displays fine but when I add breakpoints to the methods (e.g. ViewDidLoad, widgetPerformUpdateWithCompletionHandler) the breakpoints never seem to be called.

I'm trying to figure this out as I've added extra code - e.g. NSLog to display some values within the methods but do not see any output from the NSLog calls.

Can someone explain why the breakpoints are not working? I'm guessing that it has something to do with the extension methods are executing in the 'background' but am not sure.

Thanks

Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
Jazzmine
  • 1,837
  • 8
  • 36
  • 54
  • I came across this article http://www.atomicbird.com/blog/ios-app-extension-tips about setting the derived data path and ensured that my Derived Data path was set to default and Build Location under the Advanced option set to Unique Location. – Jazzmine Sep 13 '15 at 16:41
  • I'm going to try this to see if it works: http://stackoverflow.com/questions/24031612/how-to-debug-ios-8-extensions-with-nslog. – Jazzmine Sep 13 '15 at 18:50

2 Answers2

8

You are able to have the breakpoints you set in your today extension activate by following the procedure below:

1) Set breakpoint in your extension code (viewDidLoad is a good option to test)

2) Launch your app as you normally would by selecting your app's target and hitting run.

3) Make sure that your extension is installed in the today view (open the today view and hit the edit button to add it if it is not)

4) Close the today view.

5) In Xcode select your today extension target and press the run button. You will be prompted to choose an app to run. Select "Today".

6) You should see the today window appear on the simulator (this also works on the device). Your breakpoint will be hit.

NOTE: You may hit an exception breakpoint in your app prior to the today extension launching because your app is sent to the background. If this happens just skip over the breakpoint and you will hit the breakpoint in your extension as expected. This procedure also allows you to see console statements from your extension.

user3847320
  • 823
  • 9
  • 18
1

I'm not sure if this is related to your specific situation, but in an app where I have 3 extensions, I noticed that breakpoints don't work in 2 of them.

I noticed however, that the breakpoints start working if I run (from XCode) the extension on which the breakpoints work, and access one of the other extensions (from inside Photos app in my case). For some reason, running the other extensions from XCode would not trigger the breakpoints.

alex-i
  • 5,406
  • 2
  • 36
  • 56