NSUserDefaults not cleared after app uninstall on simulator NSUserDefaults not cleared after app uninstall on simulator ios ios

NSUserDefaults not cleared after app uninstall on simulator


I think this is due to a bug in the iOS8 Beta Simulator.

The expected behavior is that when the app is deleted, the NSUserDefaults for that app are deleted as well.

  • However, NSUserDefaults are NOT deleted when you remove an app from the simulator.
  • They are correctly deleted when you delete them from a physical device running iOS8.

A quick and annoying solution for now is to click, iOS Simulator -> Reset Content and Settings.

Xcode 9.2 with Simulator 10 still presents this issue. Menu option is now Hardware .. Erase All Content and Settings

I submitted a bug report btw


Since Reset Content and Settings is a nuclear option, you could consider two other options until the bug on the iOS 8/Xcode 6 GM simulator is addressed:

  1. You could manually delete the plist file where the NSUserDefaults are stored. This is currently located at ~/Library/Developer/CoreSimulator/Devices/*some_device_id*/Library/Preferences/com.yourcompany.yourapp.plist It's a little tedious to find the right simulator to work with among the UUID directory names. EDIT: 2014-10-28 20-34-52 Correct path: ~/Library/Developer/CoreSimulator/Devices/*some_device_id*/data/Library/Preferences/com.yourcompany.yourapp.plist

  2. You could perform "surgery" on that plist (using a run script build phase perhaps) using plistbuddy e.g.

/usr/libexec/plistbuddy -c "Set :BSDidMoveSqliteDb 0" path_to_plist


For anyone facing the same issue.

If you have more than 1 app under the same group and all of them are using app groups (ON under capabilities), then you will have to remove all the apps from the device in order for the user defaults to be cleared.

Since the user defaults are shared, even if one of the app is on the device then it will not be deleted, as that app will be using the userdefaults.