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 • 3 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

Hi guys, any update on this? @justin-fiedler

tcldr avatar May 16 '24 13:05 tcldr

it's been almost a year since this ticket was opened any update?

rakefetWorkiz avatar Oct 28 '24 13:10 rakefetWorkiz

Any update on this? We cannot release right now, because of this folder appearing alongside the user's documents. It would be great to at least get some guidance on how to properly implement the Storage interface. Also when implementing the Storage interface, this means future migrations will not catch the custom storage at all, placing even more burden on library users.

Right now we are considering to roll back to the Obj-C SDK because of this.

kaiengelhardt avatar Feb 13 '25 14:02 kaiengelhardt