Here's a rather embarrasing example of data storage rot[0].
> Don't do that, that'll delete all the data as well.
Not necessarily, but it depends on the app.
I use the User Defaults dictionary all the time, for things like operational prefs. I even have an SPM module that I wrote for it[1]. User Defaults gets deleted with the app, unless you do some hacking to sync it somewhere else.
I think that storing as an app file may also get deleted when the app is deleted.
We're not supposed to use that for persistent data, though. Apple provides Core Data for that kind of thing (a mixed bag). Even that needs to be done correctly, like storing using iCloud (Disclaimer: I have not chosen to use Core Data for my apps, so I can't speak to it authoritatively).
Or you could do what I do: Use a server.
[0] https://www.theguardian.com/uk/2002/mar/03/research.elearnin...
[1] https://riftvalleysoftware.com/work/open-source-projects/#RV...
more fun facts: user defaults has a limit to how big it can be. And I also think that your library would benefit from using actual types instead of Any, you can actually define this so long as the value is Codable, generics would make the library nicer to work with instead of requiring the dev to cast the type themselves. You basically just switch out Any for a generic and have the Generic conform to Codable. If targeting an iOS version that is 14+ I would just recommend using the AppStorage or SceneStorage property wrappers.
I'll probably do that. I started it years ago, so it has a lot of legacy. I will probably do a refactor, when I come up for air. A couple of my libs could use a facelift.
Offloading and reinstalling the app fixed the problem!