Skip to content

Instantly share code, notes, and snippets.

@nurimelih
Created December 9, 2025 12:04
Show Gist options
  • Select an option

  • Save nurimelih/4235a6c223938770260d8006df3f9b78 to your computer and use it in GitHub Desktop.

Select an option

Save nurimelih/4235a6c223938770260d8006df3f9b78 to your computer and use it in GitHub Desktop.
Open Realm DB in Realm Studio for active iOS Simulator
# Realm DB - find and open for active iOS simulator
# Usage: Add to ~/.zshrc, then run: source ~/.zshrc && realm-open
realm-open() {
local booted=$(xcrun simctl list devices booted -j | python3 -c "
import sys,json
d=json.load(sys.stdin)
sims=[(u['name'],u['udid']) for devs in d['devices'].values() for u in devs if u.get('state')=='Booted']
for name,udid in sims: print(f'{name}|{udid}')
")
local count=$(echo "$booted" | grep -c '|')
if [[ $count -eq 0 ]]; then
echo "No booted simulator found"
return 1
elif [[ $count -eq 1 ]]; then
local udid=$(echo "$booted" | cut -d'|' -f2)
else
echo "Select simulator:"
local i=1
echo "$booted" | while read line; do
echo " $i) $(echo $line | cut -d'|' -f1)"
((i++))
done
read "choice?Enter number: "
local udid=$(echo "$booted" | sed -n "${choice}p" | cut -d'|' -f2)
fi
local realm_file=$(find ~/Library/Developer/CoreSimulator/Devices/$udid -name "*.realm" 2>/dev/null | head -1)
if [[ -n "$realm_file" ]]; then
echo "Opening: $realm_file"
open -a "Realm Studio" "$realm_file"
else
echo "No realm file found"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment