I have an app I am working on that makes a REST call, updates the UI with the info, and sends a notification. When I run Build and Run my app from Xcode using my iPhone as the destination, it works exactly as I want it to - my REST calls and notifications continue to work when the app is in the background.
However, when I run my app that has been installed on my iPhone from the Xcode build/run directly (without Xcode in the picture), it does NOT behave correctly and only works when my app is in the foreground.
What am I missing?
@briggr1 Thanks for the post, it's not a bug that Xcode does not allow Timer to run in the background. I would recommend to read my answer again about how the background process works but I may have failed to explain it well, I have been known to make that mistake, let me try it again.
When you launch an app via Xcode (Build and Run), the Xcode debugger attaches to your app's process. To prevent the debugger from randomly disconnecting, iOS disables standard background suspension rules. Your app is allowed to run continuously in the background, consuming as much CPU and battery as it wants, so you can debug it. Now this is not the way on released apps.
I think previously I have recommended to other users to move the process to as server to avoid using the device as to process the work.
Also I think have previously recommended to go over this great documentation about how to use background processing:
https://developer.apple.com/documentation/uikit/preparing-your-ui-to-run-in-the-background
Hope this all helps
Albert Worldwide Developer Relations.