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.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
/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.
Another way to do it is to use a temp file that redirects to the URL you want, then opening this file in the simulator. This isn't necessarily the best way, but it is a shorter command.
echo "<meta http-equiv="refresh" content='0;url=http://apple.stackexchange.com'>" > ~/tmp/openURL.html; open ~/tmp/openURL.html -a /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/
As in the other answers, you can replace the URL (I put apple.stackexchange.com) with whatever you want. Just make sure you put http:// because
open interprets arguments as filesystem paths by default.
Sadly, the bulk of the command is just the path to the iPhone Simulator bundle.