Confused about app updates and game data. Do you lose library data or not?

The following question:

https://developer.apple.com/forums/thread/115819

is answered by saying that an app update will cause user data in the library directories to be erased. I tried updating a build in TestFlight and it seems this is not the case. However, a tester updated and had elements of the old build remaining. Having to delete the app and reinstall to solve this problem, his game data was erased, as expected.

I am currently saving the player's game data (a codable object of about 30K) in the caches directory and am concerned that once the app is on the App Store, that any app updates (for bug fixes or whatever) will erase the player's progress. I don't mind that deleting the app will delete all the data, but I want the data to persist across updates.

Could someone please clarify whether or not an app update deletes the caches directory and starts anew and if it does, what's the recommended way to make user data persist across app updates?
Answered by DTS Engineer in 619927022
The Documents directory is not necessarily exposed to the user but, if it is then, yeah, it’s not appropriate for this.

If the Documents directory doesn’t work for you, see QA1699 Storing Private Data.

Share and Enjoy

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

I am currently saving the player's game data (a codable object of about 30K) in the caches directory

If you want data to persist, do not store it in the Caches directory. The system is free to delete that directory any time that your app your app is not running (if your app is suspended in the background, and the system really needs space, it will terminate the app before doing this).

The canonical place for data that’s important to the user is the Documents directory.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks. But the document directory is exposed to the user.
I could put it in the Application Support directory, but how do I assure game data persists when the app is updated? Do I have to send it to iCloud? It's only a small amount of data in a property list.
Accepted Answer
The Documents directory is not necessarily exposed to the user but, if it is then, yeah, it’s not appropriate for this.

If the Documents directory doesn’t work for you, see QA1699 Storing Private Data.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
That sounds useful. How do you use the documents directory without exposing it to the user?
Confused about app updates and game data. Do you lose library data or not?
 
 
Q