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

5

25

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.
Aconite answered 11/10, 2012 at 9:13 Comment(6)
Which version of Xcode are you using? Note that Xcode 4.5 only supports iOS5 and higher simulators.Bunyan
yes i am using 4.5, and i am able to run my scripts(by choosing different versions of simulators) through the the UI interface of instruments. i m unable to acheive the same using command line interfaceAconite
Hav you tried something like this? /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /Users/user/Library/Application\ Support/iPhone\ Simulator/SIMULATOR VERSION HERE/Applications/016SA6CB-W70F-4368-BF48-A0E65466F7EE/yourappname.appSerles
Yes , i tried the exact same thing initially,but it does not work.Aconite
I am trying to solve the exact same problem ... 12 hrs in I gave up. I think instruments decides the version to launch no matter what hack you inject it with. I couldn't try it myself but would it work if you compile your app using "xcodebuild -sdk iphonesimulator5.1 -target APP", and see if it picks 5.1 by default?Sharpeared
@e_x_p I tried building the app for specific versions, but that didn't make a difference.Disinfection
E
6

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

Endocentric answered 7/5, 2014 at 12:32 Comment(0)
A
2

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.

Amused answered 8/10, 2013 at 22:46 Comment(1)
looking for a command-line way to do this. I tried saving an Instruments template made this way, but it still started the latest version from the command line.Placia
H
0

Have you tried iOS-Sim https://github.com/phonegap/ios-sim ? This gives you some extra options when working with the simulator from cmd. The Version is one of these.

Herculaneum answered 13/11, 2012 at 15:0 Comment(1)
I don't think ios-sim would help because no matter what OS version the simulator is running before you kick off the Automation instrument it seems to change it to the latest (currently 6.1)Disinfection
A
0

If you can select it on the UI, you should be able to achieve the same result using applescript. This is an example of how to change the Device on applescript: https://gist.github.com/Reflejo/9537281

Alasteir answered 13/3, 2014 at 21:26 Comment(0)
J
0

tried something like this?

xcrun instruments -v -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate ~/Library/Application\ Support/iPhone\ Simulator/6.1/Applications/00C7521A-92D9-4627-BB1D-2CD7CA605B9B/Mobile\ EMR.app -e UIASCRIPT /Volumes/Data/SoftServe/Projects/mEMR/imHealth/Testing/testUI.js -e UIARESULTSPATH /Volumes/Data/SoftServe/Projects/mEMR/imHealth/Testing/results.txt
Jeffries answered 8/4, 2014 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.