How to launch browser in iOS Simulator from command line?

I want to launch the browser in iOS Simulator from the Terminal with specified URL.

Is there any command for it? So that I can write in a script which will take URL as argument and launch simulator with browser and URL open on it.


Solution 1:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Applications/MobileSafari.app/MobileSafari -u "http://google.com/"

Yes this really is one long command — make sure to run it all. Replace google.com with actual website, and iPhoneSimulator7.0.sdk with the relevant version of the simulator that you're using.

Solution 2:

On Xcode6 simctl was introduced so you can just open the terminal and type:

xcrun simctl openurl booted "https://google.com"

Solution 3:

The path has changed for Xcode 6.0 (OS X Yosemite) and now it's:

alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app'