Open the iOS Simulator from the Command Line

1 minute read

When I need to test web apps on an iPhone or iPad, I use the iOS Simulator that ships with Xcode1. The Simulator is intended for developers testing native apps, however, Mobile Safari is installed and I can use it to debug apps without a physical device. I’m lazy and don’t want to open up Xcode just to get to the Simulator. Fortunately, it’s a standalone app that lives in /Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app. That’s way too much to type, aliases to the rescue. Bash:

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

For {t,}csh the difference is an =:

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

Bonus Tip #1

localhost works in Mobile Safari in the Simulator allowing you to connect to any dev servers you have running.

Bonus Tip #2

With Mobile Safari running in the Simulator, open desktop Safari. Under Develop you’ll see iOS Simulator and under that a list of any pages you have open in Mobile Safari. Select one to have full access to it using Safari’s Developer tools and Javascript console. No more debugging with alert()!

Put the alias and the tips together and you can develop without pulling your phone out of your pocket.

  1. Xcode 6 that is. If you’re using Xcode 5 it was /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app.
    If you are using Xcode 4, I can’t help you. 

Comments