I'm trying to make sure my first-run code works properly, and so I'd like to clear the preferences file created by UserDefaults.standard.set
calls. Where is it located, or is there at least a way to clear it out (other than writing it into my app)?
Running Product > Clean does not clear out the defaults.
I've looked in DerivedData, ~/Library/Preferences, /Library/Preferences, and haven't found what I'm looking for.
To remove a key-value pair from the user's defaults database, you need to invoke removeObject(forKey:) on the UserDefaults instance. Let's update the previous example. The output in the console confirms that the removeObject(forKey:) method works as advertised.
Navigate to AppData -> Library -> Preferences. The property list file (. plist) in this folder is the database file of the standard UserDefaults of your app.
An interface to the user's defaults database, where you store key-value pairs persistently across launches of your app.
You can use defaults
command In Terminal
$ defaults delete com.bundle.identifier
Also you can delete any value in defaults by key, if you don't want to delete whole application defaults plist.
$ defaults delete com.bundle.identifier kSomeKey
If the app is sandboxed the preferences are located in
~/Library/Containers/[bundle-identifier]/Data/Library/Preferences
If it's not sandboxed the preferences are at the usual location
~/Library/Preferences
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With