Sample code for how to run UI Automation from the command line.
Shell Objective-C JavaScript
Latest commit 4be0a2e Sep 10, 2014 @jonathanpenn Merge pull request #6 from johngibb/master
specify field separator to allow arguments with spaces
Failed to load latest commit information.
AutomationExample Changed Apple template to use static table cells Jun 28, 2012
.gitignore Don't include automation results Jun 28, 2012
Default-568h@2x.png Added iPhone 5 trigger png Oct 26, 2012
LICENSE Added the MIT license Oct 26, 2012
README.markdown Explain what's happening with TARGETED_DEVICE_FAMILY Jan 21, 2013
UIAutomationTemplate.tracetemplate Include the basic automation steps Jun 28, 2012
env.js Fixed how detail screen was accessed (changed in iOS 7) Sep 18, 2013 Add comment for testing universal app on iPad Simulator (for #3) Jan 21, 2013
unix_instruments specify field separator to allow arguments with spaces Sep 10, 2014



This is a demo app to showcase how to run UI Automation scripts from the command line.


You need to have at least Xcode 4.5 along with the command line tools.

Running The Demo

Just open a terminal window, change to the project directory and run this:


It will build the application with xcodebuild in the /tmp directory and then execute it with my unix_instruments wrapper that ensures that Instruments returns a proper exist status code when a test fails. You can read more about how that works in the copious comments.

Running on iPad Simulator

For some reason, Instruments will always launch a universal app in the iPad simulator when launched from the command line. This happens even if you change the simulator device type explicitly in the menu. To get this to work, you need to rebuild the app and tell Xcode to explicitly choose one of the device family types like so:

xcodebuild -sdk iphonesimulator clean build \

Setting TARGETED_DEVICE_FAMILY to 1 changes the Info.plist file so that build is only for iPhone. Setting it to 2 makes it only for iPad.