Is there a straightforward way to clean up the directory where xcode deploys an app when building for the iPhone simulator? I have a sqlite database that gets copied into t
Clear Xcode Cache;
Command+Option+Shift+K
Command+Shift+K
(Use both of them because they have different functionality)
Clear Derived Data content ;
Menu Bar -> Window -> Organizer -> Projects -> Select Your Project
Right Pane shows the name of folder and also delete button at the right side allows you to delete all derived data contents.
Clear Simulator Cache;
Menu Bar -> iOS Simulator -> Reset Contents And Settings
As I was explaining in a comment under the validated answer:
I was testing adding and removing calendar subscriptions. On a real device, you can remove a calendar subscription in Settings, Accounts but this menu does not exist in iOS Simulator and I did not want to reset the whole simulator.
So I ended up locally versioning my Device folder with git and perform the following commands to remove a calendar subscription after I added it:
$ git reset HEAD --hard
$ git clean -f
So the steps are:
~/Library/Developer/CoreSimulator/Devices/
and do a cd
to it, then git init
to create a git repositorygit commit -a "Message"
git reset --hard HEAD
git commit
are gone. If you are using Xcode 9 -> Menubar -> Hardware -> Erase All Content and Settings
This works with Xcode 6:
xcrun simctl list | grep -oh '[A-Z0-9]\{8\}-[A-Z0-9]\{4\}-[A-Z0-9]\{4\}-[A-Z0-9]\{4\}-[A-Z0-9]\{12\}' | xargs -I{} xcrun simctl erase {}
For .bash_profile
alias cleansim="xcrun simctl list | grep -oh '[A-Z0-9]\{8\}-[A-Z0-9]\{4\}-[A-Z0-9]\{4\}-[A-Z0-9]\{4\}-[A-Z0-9]\{12\}' | xargs -I{} xcrun simctl erase {}"
The way I do this is to simply click and hold on the icon for my app in the simulator--then when it starts to wiggle click the black and white (x). A message will pop up asking whether you really want to delete and you just click yes. The next time you build and deploy your app it will use the new sqlite db without a hitch and you don't have to go muck around in the filesystem.
After iOS 5 on Mac OS X Lion, you can try:
RemoveSimulatorApps.command
that contains:rm -rf "$HOME/Library/Application Support/iPhone Simulator/5.0/Applications/*"
PATH
.chmod +x RemoveSimulatorApps.command