何かしらの理由でiOSシミュレーターのキーチェーン情報を削除したい時のためのメモ
シミュレーターのUUIDを取得
1 2 3
| xcrun simctl list | egrep '(Booted)' iPhone 13 Pro Max (シミュレーターのUUID) (Booted) Phone: iPhone 13 Pro Max (シミュレーターのUUID) (Booted)
|
ファイル確認
キーチェーン情報はSQLiteのファイルとして保存されている
パス:~/Library/Developer/CoreSimulator/Devices/(シミュレーターのUUID)/data/Library/Keychains
ファイル名:keychain-2-debug.db
1 2 3 4 5 6
| la ~/Library/Developer/CoreSimulator/Devices/(シミュレーターのUUID)/data/Library/Keychains total 5832 drwxrwxrwx 17 u1 staff 544B Apr 8 08:12 Analytics -rw-------@ 1 u1 staff 788K Apr 17 10:50 keychain-2-debug.db -rw------- 1 u1 staff 32K Apr 17 10:49 keychain-2-debug.db-shm -rw------- 1 u1 staff 1.2M Apr 18 20:50 keychain-2-debug.db-wal
|
ファイルを開く
1 2 3 4
| sqlite3 ~/Library/Developer/CoreSimulator/Devices/(シミュレーターのUUID)/data/Library/Keychains/keychain-2-debug.db SQLite version 3.37.0 2021-12-09 01:34:53 Enter ".help" for usage hints. sqlite>
|
TablePlusのインストールはbrew install --cask tableplus
1
| open ~/Library/Developer/CoreSimulator/Devices/(シミュレーターのUUID)/data/Library/Keychains/keychain-2-debug.db
|

情報の削除
キーチェーン情報はテーブルgenpに保存されて、カラムagrpに書き込んだアプリのバンドルIDがあるのでそこを参考に削除可能
1
| SELECT rowid, agrp FROM genp;
|
1 2 3
| DELETE FROM genp WHERE agrp = 'TEAMID.com.your.app.bundle.id'; または DELETE FROM genp WHERE agrp like '%xxxxx%';
|

参考:https://stackoverflow.com/a/42564772