Hi, We assume that when uninstalling an application, the UserDefaults are deleted.
Starting iOS16 we encounter complaints from clients that this is not the case. We have succeeded in debugging a device where this occurred (UserDefaults were not deleted after uninstall+install), but have not succeeded in recreating this issue on another device.
We assume this issue has a connection to iCloud sync, although UserDefaults iCloud synching should be specifically set up (using NSUbiquitousKeyValueStore) which we have NOT set. Or maybe it has to do with Family Sharing.
We are initializing the UserDefaults with suiteName for usage in widgets, but assume this has not connection to the bug.
Save a parameter isNotFirstInstall in user defaults.standard. Set it to true after you do your 'first install' stuff. If you need this value in the app groups other apps, the main app should make a copy of this value under a different name in the app groups user defaults. When the main app is uninstalled and then installed again, isNotFirstInstall will be nil and then the main app can delete the values in the app groups user defaults since you know all the keys. Let me know if this helps.