Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch a specific Hardware version of iOS simulator using instruments command line utility

I am using UIAutomation provided by Apple -> Xcode -> instruments. I have my Javascripts and the whole automation using instruments command line infrastructure running up.

I got an additional task of running automation on previous versions of simulator (iOS 6.0 , 5.1, 5.0, 4.3.2) to provide better coverage.

But i do not know a way to specify which version of iOS simulator to choose from. by default it always chooses the lates iOS simulator.

I have tried the following things:

  1. Specifying the path where the simulator is kept which includes the version path of simulator.
  2. Making a custom Automation template trace and trying to use it.
  3. Changed the default version of iOS simulator using defaults write com.apple.simulator utility.
like image 996
user1737520 Avatar asked Oct 11 '12 09:10

user1737520


People also ask

How can I launch the iOS simulator from terminal?

Just type this command in Terminal: open -a Simulator. app to launch the most recent simulator. Type this command in Terminal to run the Simulator rigth from the its folder.

How do I open the simulator from the command-line?

Starting the emulator Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's the basic command-line syntax for starting a virtual device from a terminal prompt: emulator -avd avd_name [ {- option [ value ]} … ]

How do I select a simulated device in Xcode?

Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.

How do you launch a simulator?

Run your app on the emulator After you have created an Android Virtual Device (AVD), you can start the Android Emulator and run an app in your project: In the toolbar, select the AVD that you want to run your app on from the target device drop-down menu. Click Run.


2 Answers

Since Xcode 5.1 Instruments supports specifying the simulator hardware type and iOS version from the command line.

instruments -w help

The command above will give you a list about the available hardvare-iOS combinations. On my machine thats are:

iPhone - Simulator - iOS 6.1
iPhone - Simulator - iOS 7.1
iPhone Retina (3.5-inch) - Simulator - iOS 6.1
iPhone Retina (3.5-inch) - Simulator - iOS 7.1
iPhone Retina (4-inch) - Simulator - iOS 6.1
iPhone Retina (4-inch) - Simulator - iOS 7.1
iPhone Retina (4-inch 64-bit) - Simulator - iOS 6.1
iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1
iPad - Simulator - iOS 6.1
iPad - Simulator - iOS 7.1
iPad Retina - Simulator - iOS 6.1
iPad Retina - Simulator - iOS 7.1
iPad Retina (64-bit) - Simulator - iOS 6.1
iPad Retina (64-bit) - Simulator - iOS 7.1

You can specify the hardware and iOS version also with -w flag. Example:

instruments -w "iPad Retina - Simulator - iOS 7.1" -t ...

Note that -w flag must come at the start of the command line, before any other flags, otherwise you get strange errors.

I have found this information at: http://cocoamanifest.net/articles/2014/03/ui-screen-shooter-now-simpler-and-more-robust-since-xcode-5-1.html

like image 176
fabe Avatar answered Sep 30 '22 09:09

fabe


Using Instruments 5.0 (relate to Xcode 5.0):

  1. click the small "i" icon to the right of "Automation" in the upper left part of the window
  2. underneath "Target", click on the name of your app
  3. in the pop-up menu, select "Edit Active Target" in the pop-up window,
  4. click the "Options" menu, and underneath "Simulator Configuration" select the device to simulate and iOS version.

If you don't see a particular iOS version, then you need to add that simulator in Xcode:

  1. Xcode menu, Preferences...
  2. Downloads tab
  3. Click the down-arrow next to the version of iOS simulator you want to install

PS: I created some awesome screenshots, but stackoverflow won't let me post them. boo.

like image 2
user2816065 Avatar answered Sep 30 '22 10:09

user2816065