Amplitude-Swift icon indicating copy to clipboard operation
Amplitude-Swift copied to clipboard

Persistent Storage uses caches/document directory

Open tcldr opened this issue 1 year ago • 1 comments

Expected Behavior

Application data should be stored in the application support directory reachable via FileManager.SearchPathDirectory.applicationSupportDirectory.

Current Behavior

Application data is being saved to either the user's document directory or the caches directory. The document's directory is less than ideal as it clutters up user space. The caches directory is also problematic as it can be purged by the system.

Possible Solution

Use the application support directory (FileManager.SearchPathDirectory.applicationSupportDirectory). On macOS, it's the ~/Library/Application Support directory. On iOS and other platforms it's app specific, but serves the same purpose.

Furthermore, you can mark a directory/file to be excluded from iCloud backup by setting attributes at the point of creation. More info here: Mark Nonpurgeable Data as Excludable

I've created a PR you can reference

tcldr avatar Dec 16 '23 19:12 tcldr