I've stored some data in the simulator keychain for sensitive data. Now I must test what happens if that data is not yet present.
But I am unable to reset my simulator's keychain to test that.
I've tried deleting the app from the simulator and then do a reset content and settings. But the keychain data is still present.
Edit: YES, I HAVE TRIED "RESET CONTENT AND SETTINGS", but that does not work
Run and stop an emulator, and clear data To stop a running emulator, click Menu and select Stop. To clear the data for an emulator, select Wipe Data. Or click Menu and select Wipe Data.
shift+command+H twice to simulate the double tap of home button. swipe your app's screenshot upward to close it.
In the Keychain Access app on your Mac, if your keychains aren't visible, choose Window > Keychain Access. Select a keychain in the Keychains list. Choose File > Delete Keychain [keychain name].
Easiest way would be to open your simulator and go to:
"iOS Simulator -> Reset Content and Settings"
This will reset everything in the simulator and will return it to Default settings.
If you want to do it through code you can do it like this:
NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword,
(__bridge id)kSecClassInternetPassword,
(__bridge id)kSecClassCertificate,
(__bridge id)kSecClassKey,
(__bridge id)kSecClassIdentity];
for (id secItemClass in secItemClasses) {
NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
SecItemDelete((__bridge CFDictionaryRef)spec);
}
There is a race condition with resetting contents & settings sometimes not working. If it doesn't work, try again. If it really keeps on not working, quit Simulator.app
, wait a few seconds, then run xcrun simctl erase <Device UDID>
from Terminal. You can get the device's UDID by running xcrun simctl list
.
This race bug should be addressed in the latest Xcode 7 Beta.
Xcode 13.1
You can erase the keychain data on the simulator from option Device
-> Erase All Content and Settings
like the below image.
Just remember, this option will clear all current data on your simulator.
Hope to help someone!
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