Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IllusiveMilkman/eaf21178ee81b4c9ea72bfc79ed739ff to your computer and use it in GitHub Desktop.
Save IllusiveMilkman/eaf21178ee81b4c9ea72bfc79ed739ff to your computer and use it in GitHub Desktop.
This bash script should open the SQLite database of your Flutter app, while the iOS Simulator is running an instance of your app.
## This script should open the SQLite database of your Flutter app, while the iOS Simulator is running an instance of your app.
# Note the following assumptions BEFORE using this script:
# 1. You have DB Browser for SQLite installed and set as the default app for opening .sqlite or .db files. You could try alternative viewers as well, but I have not tested with another.
# 2. Flutter defaults the naming of ".xcodeproj" to "Runner.xcodeproj". This script assumes this as well.
# 3. Your Flutter app code created a database with the ".db" extension. If not, feel free to modify this code to whatever you used.
# 4. You are running an instance of your app on your iOS Simulator
#!/bin/bash
# Step 1 - Get the process ID
# You can view verbose results, and edit to your liking, with the following terminal command:
# pgrep -lf . | grep "Developer/CoreSimulator/Devices/" | grep "Runner.app"
MYID=$(ps -A | grep "Developer/CoreSimulator/Devices/" | grep "Runner.app" | awk '{print $1}')
# Step 2 - Get the DB path based on the Process ID (assumes file extension of ".db"). Feel free to modify to your needs.
DBPATH=$(lsof -Fn -p $MYID | grep "\.db")
# Step 3 - Remove the unecessary first character from the path string above to prevent "path doesn't exist" type errors.
DBPATHCLEANED="${DBPATH:1}"
# Step 4 - Open the file
open $DBPATHCLEANED
# Step 5 - Remember mark your file as executable with:
# chmod +x your_file_name.sh
# Step 6 - Run your file with:
# ./your_file_name.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment