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




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s