Category Archives: xcrun

Resetting an iPhone Simulator and Clearing Images

In theory there is this command, though I haven’t tried it yet and it requires the iPhone Simulator to be running

  • xcrun simctl erase device_UUID

Another option, which also requires the iPhone Simulator to be running is:

  • Within the iPhone/iPad simulator, go to the top-menu and select “iOS Simulator” -> “Reset Content and Settings…

However what I really need is control over the images of the device.

One Stack Flow Article mentioned this location

  • /Users/<username>/Library/Application Support/iPhone Simulator/User/Applications
    • There are a bunch of GUID files and directories. They match up to the apps you have installed on your simulator.

I couldn’t find a folder called “iPhone Simulator”, this might be due to how my installation was setup (I followed someone else’s instructions during a knowledge dump). However I did finally find my Simulator files under “Developer”


  • /Library/Developer/CoreSimulator/Devices
    • Under Devices is a list of Directories that use the¬†GUID as the folder name, you can find these GUID’s in the device list in the iPhone Simulator


Now that you found the directories you can remove the images if you wish, but going to a sub-directory under data (under your device)

  • /Library/Developer/CoreSimulator/Devices/GUID/data/Media/DCIM/100APPLE


  • /Library/Developer/CoreSimulator/Devices/06BF26ED-6892-4BAF-9D94-5D92171A7C1A/data/Media/DCIM/100APPLE
    • I’m not sure if the sub-directory is always called “100APPLE” but that is the image directory




So resetting the iPhone Simulator, puts all the default photos back (like roaches ūüôā , they can’t be nuked by a reset).¬† So the search continues, and I do dislike postings the same “manually” drag photos or something, that kind of defeats the purpose of automation.



Adding an image to the iPhone Simulator via the command line

So from the notes I was given, this is the command to make it work

xcrun simctl addphoto 6A0CB955-C22B-48A6-A7F5-809806EB57F2 /Users/username/Dropbox\ \(Evernote\)/Scannable\ Image\ Library/Moleskine.jpg

Which failed for me.

An error was encountered processing the command (code=146):
Invalid device state

Then I found out that you need the iPhone Simulator running first to make this work, considering I got the notes and overview in a knowledge before someone left the company, I can understand how details like that were lost.

So you need the iPhone simulator running and the command will add an image to the iPhone Simulator (though this caused other failures for)

So Command Usage

  • xcrun (Run or locate development tools and properties Command line)
  • simctl (Command line utility to control the iOS Simulator)

So me in this case I need to add a photo for processing by our app, fortunately there is a command “addphoto”

  • xcrun¬†simctl¬†addphoto (Device ID) /PATH To Image
    • Note 1: Simulator needs to be running for this command to work
    • Note 2: You can drag an image to the command line and OSx will put in the path to the image for you
  • Example: xcrun¬†simctl¬†addphoto¬†6A0CB955-C22B-48A6-A7F5-809806EB57F2 /Users/username/Dropbox\¬†\(Evernote\)/Scannable\¬†Image\¬†Library/Moleskine.jpg
    • username = your actual username