2

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.

1

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
  • It just launches the simulator and does nothing else. Do I need to replace Safari with something else? – Vivek V Dwivedi Feb 6 '15 at 11:07
  • 2
    I think @VivekVDwivedi meant MobileSafari, not the desktop one... open -a opens the desktop applications. – Igor Hatarist Feb 6 '15 at 11:43
  • Yes, I meant the mobile safari. I am working on automation but unable to find a way till now to launch the mobile safari with simulator in a single command. I have a shell script which does the job, but I am still researching to get this shell script out. – Vivek V Dwivedi Feb 6 '15 at 12:09
  • Please see my update. – Matthieu Riegler Feb 6 '15 at 12:55
  • @VivekVDwivedi You probably need to add a sleep 5 in between the two commands to wait for the simulator to boot. – jessepinho Nov 30 '17 at 13:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .