Can an app be killed even in the background state?

I know ios apps have the following lifecycle.

  • active
  • background
  • suspended
  • not running
  • inactive

My question is if my app can be killed in background state in the lifecycle above? Especially, I'm using beginBackgroundTask(expirationHandler:) to extend background time before suspended. Then my app is terminated with the following message without expirationHandler being called.

Message from debugger: Terminated due to signal 9

Does this potentially happen? Actually I'm runnning a heavy task that requires CPU usage in background state, so is this a cause of this problem?

Replies

Then my app is terminated

What do you mean by “terminated” in the above? Do you mean “terminated by the user by swiping up in the multitasking UI”?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo Thank you for the reply! Sorry I needed more context to explain. When I switch to another app or move to home of iPhone, then my app is terminated automatically 3 or 4 seconds after I leave my app!

If apps shouldn't be killed in background state, the termination after 2 or 3 seconds is strange because I extended time for background state.

When I switch to another app or move to home of iPhone, then my app is terminated automatically 3 or 4 seconds after I leave my app!

If you create a new test project from one of the built-in templates, do you see the same behaviour with that?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"