Is there a quicker / better way to clear the iPhone Simulator cache than deleting its directory?
So I'm still reasonably new to iOS development and I'm finding myself quite regularly needing to delete either DerivedData, or the contents of the iPhone Simulator directory, to get things to actually execute from my code. Clean in Xcode doesn't do the same as emptying those directories, right? And if not, is there an easier way to do it than lugging Finder around to get to them, and clearing them?
Yes, there is a better way than going into every single simulator in town, and resetting contents and settings one at a time. Also much better than looking into your simulator's directory and yanking the cache from under its feet.
Quit iPhone Simulator, then run xcrun in Terminal:
xcrun simctl erase all
Safe and effective.
In the iOS Simulator menu, there is an option called Reset Content and Settings...
This should do the trick.
To make this much quicker and easier, I added a shortcut key like this...
In System Preferences, choose Keyboard
Then click Application Shortcuts
Click the plus button to add another shortcut.
- Choose iOS Simulator from the Application: drop-down.
- Type Reset Content and Settings... into the Menu Title: text-box.
- Type your preferred shortcut key into the Keyboard Shortcut:. (I use command-period)
- Click the Add button.
Now, while in your iOS Simulator, you can simply use your new shortcut key to reset.
If the Simulator doesn't appear in the drop down list:
- In a Finder window, go to your Applications folder.
- Right-click Xcode and choose "Show Package Contents".
- Navigate to Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/
- You will see iPhone Simulator.app.
- Now, in the Settings app, instead of choosing iOS Simulator which is missing, you choose Other....
- This will cause a window to appear that has a list of Applications.
- Now, drag iPhone Simulator.app from your Finder window to the window that appeared when you clicked Other....