If I use the sandbox Application Support directory for persistence of app data, will that data be lost whenever there is an update to the app?

I have learned that with the sandbox architecture, each app has its own local directory and can only see outside of this if entitlement is made by user requesting a specific read or write location. I want to store persistant data between app usage. Sandbox protects me from doing that. Since many apps require update yearly, I am concerned that the persistance will be lost.

Replies

>want to store persistant data


When asking such questions, it can help to be specific - starting with how much data, what type(s).

No. That is what those sandbox locations are for. However, "app zapper" apps are popular and they will delete your data. Nothing you can do about that except deal with angry customers.

I am not familiar with "app zapper" aps. Please expand your comment.

I am not familiar with "app zapper" aps. Please expand your comment.


That's just one of the complications of the macOS environment. You have to worry about vandalism to your app or its data from users or other developers. There are whole categories of apps that are designed to uninstall, "clean up", or "control" your app. Don't bother suggesting to users that they not use these apps. Users adore them. But until Apple finally goes all-in on iOS for the desktop, you have to live with them.


You don't need to take any action in your app. Just do what you should do. Store app settings in user defaults. If you have more data than is appropriate for user defaults, store it in the appropriate directory such as "Application Support". In the sandbox, there are a few such locations you can use because "Documents" and directories under "Library" are private to the sandbox.


But, if users report problems, you always have to ask about "app zappers", "clean up", "Little Snitch", and antivirus app. Any of these can block, delete, and/or corrupt your app or it's data.


PS: You mentioned "environment variables" above. While these do exist on the Mac, they are typically not useable as such, at least not in the traditional sense. You should expand on what you are attempting to do.