How do I reset the keychain in simulator?

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


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 ' 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.


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);
}
链接地址: http://www.djcxy.com/p/27300.html

上一篇: 返回的关系太多

下一篇: 如何重置模拟器中的钥匙串?