User-Generated Files in Documents Directory Deleted After App Restart on iOS 18.2 (iPhone 11)

Hello,

I am encountering an issue with user-generated files stored in the Documents directory on an iPhone 11 running iOS 18.2.

The problem occurs as follows:

1.The app generates and saves files in the Documents directory using FileManager. 2.These files are successfully saved and remain accessible while the app is running. 3.After restarting the app, the files appear to have been deleted from the Documents directory.

I have confirmed that:

1.The files are being saved to the correct location (Documents directory) and can be accessed during the current app session. 2.The app is not explicitly deleting these files during shutdown or restart. 3.This behavior is consistent across multiple app restarts.

Thank you for sharing the post. Could you kindly share the code you use to store those documents?

Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.

It appears or it behaves like the application may be utilizing a temporary folder instead of the document folder to store files. Consequently, after the application is no longer in use, the temporary files may be deleted. I would be interested in learning more about your implementation.

This issue is specific to that device, have you attempted using the simulator or another device?

Additionally, there is the possibility of a full storage capacity. Are there any exceptions when saving files? Are you utilizing an iCloud folder? I eagerly to be reviewing your project to figure it out what’s going on.

Albert Pascual
  Worldwide Developer Relations.

User-Generated Files in Documents Directory Deleted After App Restart on iOS 18.2 (iPhone 11)
 
 
Q