pretty

Saturday 15 April 2023

Inspect sqlite database file from iOS emulator

1. View sqlite file location.

Launch XCode and follow these steps:
- XCode Menu Bar > Product > Scheme > Edit Scheme
- Run option
- Add or modify the Arguments passed on launch to contain -com.apple.CoreData.SQLDebug 1
- Launch the application and wait for Output to have a string with db location, like:

CoreData: annotation: Connecting to sqlite database file at "/Users/user/Library/Developer/CoreSimulator/Devices/DA54BPCB-39F1-4D19-888A-FA146477606DD/data/Containers/Data/Application/567443-7273-4B75-BFDA-86756/Library/Application Support/Data.sqlite"

2. Knowing the location, open Terminal and cd into SQlite db location. It may look like this:

cd "/Users/user/Library/Developer/CoreSimulator/Devices/DA54BPCB-39F1-4D19-888A-FA146477606DD/data/Containers/Data/Application/567443-7273-4B75-BFDA-86756/Library/Application Support/"

Copy 3 database files from this directory to desktop, or some other convenient directory:
cp Data.sqlite /Users/user/Desktop
cp Data.sqlite-shm /Users/user/Desktop
cp Data.sqlite-wal /Users/user/Desktop

3. Open the copied Data.sqlite from /Desktop with apps from AppStore, like Ridill SQLite or SQLiteFlow.