John Marc - Novel Tip: Setting breakpoint with command && continue

John Marc

Follow @ioloro on Micro.blog.

Novel Tip: Setting breakpoint with command && continue

In some cases you want to be able to run a command once a certain part of your code is executed. An example is setting a breakpoint after BGTaskScheduler.submit(), which then executes a command to force run that task.

https://developer.apple.com/documentation/backgroundtasks/starting_and_terminating_tasks_during_development

How this would work in real time:

  • Write BGTaskScheduler.submit()
  • Set a breakpoint immediately after submitting
  • Build and run
  • App stops at breakpoint
  • Run hand currated snippet
  • Continue

Instead, we can set the breakpoint and modify the breakpoint to handle all of that!

  • Set breakpoint where you wish Breakpoint set on submitting a background task to the scheduler
  • Go to breakpoints tab in left column
  • Right click on the new breakpoint, click Edit
  • Set Action to “Debugger Command”
  • Enter the command Secondary window, editing a breakpoint with options to complete actions and continue running app
  • Optionally, select to “Automatically continue after evaluating actions” which will continue running the app and not stop

Success! Now you will hit the location in your code, automatically input the command and (optionally) continue running your app without doing anything else.