Sometimes during iOS development, you want every run to start with a completely fresh app installation – without leftover UserDefaults, local files, or other application data. A tiny simctl trick, but very useful when testing first-launch behavior or anything that depends on a clean application state.
You can automate this in Xcode using a Scheme Pre-action.
Go to:
Product → Scheme → Edit Scheme… → Run → Pre-actions
Add a Run Script Action with:
xcrun simctl uninstall booted com.example.MyApp || true
Replace com.example.MyApp with your app’s bundle identifier.
booted targets the currently running iOS Simulator. The || true ensures that the script doesn’t fail when the app isn’t installed yet.
Now every time you run the app, Xcode will:
1. Uninstall the existing app from the simulator
2. Build the new version
3. Install it with a fresh data container
4. Launch it

Leave a Reply