Swift Testing deinit not supporting async

Why doesn’t deinit support async? At the end of a test, I want to wipe data from HealthKit, and it’s delete function is asynchronous.

Answered by DTS Engineer in 795379022
Why doesn’t deinit support async?

Asynchronous deinitialers are an ongoing topic of conversation on Swift Evolution. The specific proposal was SE-0371 Isolated synchronous deinit, and you can follow links from there to the various discussion threads.

Depending on your specific goals, there may be ways around this. One option is to kick off a new task to do the clean up, and then not wait for it before returning from your deinitialiser.

Share and Enjoy

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

Accepted Answer
Why doesn’t deinit support async?

Asynchronous deinitialers are an ongoing topic of conversation on Swift Evolution. The specific proposal was SE-0371 Isolated synchronous deinit, and you can follow links from there to the various discussion threads.

Depending on your specific goals, there may be ways around this. One option is to kick off a new task to do the clean up, and then not wait for it before returning from your deinitialiser.

Share and Enjoy

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

Swift Testing deinit not supporting async
 
 
Q