snippets

Test Background Task in Xcode

2026-10-16

I am absolutely going to forget this (again) but if your app has a background task scheduled with BGTaskScheduler you can manually trigger it by pausing the app in the Xcode debugger and running the debug command

e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.your.domain.task-id"]

When you continue the app it will trigger your background task.

You have to do this on a real device since BGTaskScheduler is not present on simulators.