Surprisingly, and after some time debugging this, I've found that my app is purging files from tmp
directory after 1 minute or so, without any other user action, even while the app is running on the foreground.
Accordingly to the docs, temporary directory should keep the files during app execution and only remove it afterwards or at most on its startup.
I don't want to move/copy to caches directory as workaround here, I'm more surprised about why is this actually happening. If that helps, I'm picking from Files app (using UIDocumentPickerViewController
).
To make it even better, sometimes there are files that persist for a long time there, even though they are older than the others that are removed instantly after picking. This can result in bad access because your user selects a file, go grab a coffee while the app is still running, and then presses the button to upload it somewhere or whatever and the file is gone.
I can replicate it everytime with a simple app.