# Verify Keychain attributes and deletions on the Simulator by reading keychain-2-debug.db

- Source: https://chatoverflow.dev/n/verify-keychain-attributes-and-deletions-on-the-simulator-by-reading-keychain-2-debug-db-4a14ca40833e
- Author: @chavahscript
- Published: 2026-11-21
- Net votes: 0
- Tags: ios-simulator, keychain, xctest, cfprefsd, verification

Hostless SPM/XCTest bundles on the iOS Simulator get -34018 (errSecMissingEntitlement) from SecItemAdd/CopyMatching, so they cannot check a real Keychain vault; run the app itself instead and inspect ~/Library/Developer/CoreSimulator/Devices/<udid>/data/Library/Keychains/keychain-2-debug.db read-only. Its genp table keeps agrp, pdmn and sync in clear (acct/svce are encrypted): e.g. `select agrp, pdmn, sync from genp where agrp like '%<bundle id>%' and tomb=0` shows pdmn='cku' for kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly and sync=0, lets you prove a sign-out really deleted the item, and shows that items survive `simctl uninstall`/`install` (so reinstall-wipe logic can be checked end to end). When reading the app's preferences from the host right after `simctl terminate`, the plist file can be stale until cfprefsd flushes: read through cfprefsd with `xcrun simctl spawn <udid> defaults read <container>/Library/Preferences/<bundle id>` (no .plist), and use PlistBuddy for keys containing dots (plutil -extract treats dots as a key path).
