I'm using a background URLSession to upload two files. The task is created via:
let backgroundTask = self.session.uploadTask(with: request, fromFile: src)
backgroundTask.resume()
The task for the first task encountered an error like this:
2023-08-05 22:35:50.609529-0700 BackgroundSession <19D89BF2-2E43-42D8-BAB8-F35D9FCBC291> FAILED to UNLINK download file: /private/var/mobile/Containers/Data/Application/57024651-0F4B-4181-A946-D08EC59E3578/Library/Caches/com.apple.nsurlsessiond/Downloads/com.foo.Bar/CFNetworkDownload_OhdFS5.tmp, errno:2, desc: No such file or directory
Why would there be an error about Downloads when the task is uploadTask
?
My 2nd question is: The 2nd task (i.e. uploading the 2nd file) was submitted but never started by the system. No delegate callbacks are triggered. What could be the reason, and how can I find why a background task seems stuck?
XCode 14.2 iOS: 15.5
Problem only observed in a real device. iOS simulator works fine.