问题
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:
- Specifying the path where the simulator is kept which includes the version path of simulator.
- Making a custom Automation template trace and trying to use it.
- Changed the default version of iOS simulator using defaults write com.apple.simulator utility.
回答1:
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
回答2:
Using Instruments 5.0 (relate to Xcode 5.0):
- click the small "i" icon to the right of "Automation" in the upper left part of the window
- underneath "Target", click on the name of your app
- in the pop-up menu, select "Edit Active Target" in the pop-up window,
- 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:
- Xcode menu, Preferences...
- Downloads tab
- 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.
回答3:
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.
回答4:
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
回答5:
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
来源:https://stackoverflow.com/questions/12836129/launch-a-specific-hardware-version-of-ios-simulator-using-instruments-command-li