IOS – How to launch an iOS Simulator with Safari open using a single command

ios-simulatorterminalxcode

I am looking for a solution to launch the iOS Simulator from command line with Safari launched by default. Launching the simulator from command line is easy. So is the launching of Safari. But I want (rather need) to do this in a single command line statement which will be executed from some third party tool. Is there a possible way to do this?

I have Xcode 6.0 installed with me on OS X version 10.9.4. For now, I am starting the simulator using xcrun instruments -w "iPhone 6 (8.1 Simulator)"

But I am not able to figure out if we can pass extra arguments to this statement so that it launches Safari as well.

Best Answer

You can open a webpage in safari using :

xcrun simctl openurl <Device UDID> http://www.google.com

You can determine the Device UDID by running xcrun simctl list

Just run both command using the && operator.

xcrun instruments -w "iPhone 6 (8.1 Simulator)" && xcrun simctl openurl <Device UDID> http://www.google.com