Category Archives: xcrun
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”
- 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)
- 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.
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