Skip to content

Instantly share code, notes, and snippets.

@tunaitis
Created December 8, 2024 20:20
Show Gist options
  • Select an option

  • Save tunaitis/ad3fec3a32cede45dd54870ec61963c6 to your computer and use it in GitHub Desktop.

Select an option

Save tunaitis/ad3fec3a32cede45dd54870ec61963c6 to your computer and use it in GitHub Desktop.
A bash script to clean up all app data for testing macOS app's first launch experience
#!/bin/bash
# Configuration
APP_ID="com.your.app-id"
APP_NAME="YourAppName"
echo "🧹 Cleaning ${APP_NAME} data..."
# Clear preferences
defaults delete ${APP_ID} 2>/dev/null || true
echo "✓ Preferences cleared"
# Clear app data, caches, and saved state
rm -rf ~/Library/Application\ Support/${APP_NAME}
rm -rf ~/Library/Caches/${APP_ID}
rm -rf ~/Library/Saved\ Application\ State/${APP_ID}.savedState
echo "✓ App data, caches and saved state cleared"
# Clear SwiftData store
rm -rf ~/Library/Containers/${APP_ID}/Data/Library/Application\ Support/default.store
echo "✓ SwiftData store cleared"
# Clear keychain items
security delete-generic-password -l "${APP_NAME}" -D "application password" ~/Library/Keychains/login.keychain-db 2>/dev/null || true
echo "✓ Keychain items cleared"
# Reset app permissions
tccutil reset All ${APP_ID} 2>/dev/null || true
echo "✓ App permissions reset"
echo "✨ Cleanup complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment