#iosdev #userdefaults
@jaredsinclair @adam I haven't worked on UserDefaults since 2018, but historically a leading cause of issues like this was "something causes the app to be launched before first unlock, when defaults aren't readable".
One other cause was cfprefsd running out of file descriptors, but that only happened once and I fixed it in a way that I think would be fairly difficult to re-break.
@Catfish_Man Thanks for the reply! Unless there is a specific iOS bug behind this, my guess is that it’s the “app launch before first unlock” that’s happening. If so, something must have changed in iOS 17.x that’s causing this to happen now, somewhere… but where? My widget extension? Intents extension? Something with live activities?
(Can an extension launching before first unlock blow away user defaults for the whole app?)
@adam it would be an OS bug regardless since it’s not supposed to put apps in that situation.
The workaround if that’s the case would be to make sure you detect empty defaults and don’t write to them, and then they’ll be back when you launch for real. The permanence of it is setting a value into the empty defaults, causing it to be written out to disk.