10

I recently updated to Xcode 6 and now the command I was using before doesn't work:

/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/"

I do a lot of front end work and responsive design and must look at the results in every browser multiple times a day. It is very painful without this command.

Also, I would like to open in IOS7 with one command and IOS8 with another.

Community
  • 1
  • 1
Stoutie
  • 1,944
  • 1
  • 21
  • 17

1 Answers1

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

You can determine the Device UDID by running xcrun simctl list or on newer versions, you can use "booted" instead of the UDID to refer to the currently booted device:

xcrun simctl openurl booted http://www.google.com

Note that this requires the iOS Simulator to actually be running. Depending on the version of Xcode.app that you have, you may be able to use the "booted" alias instead of the device UDID to select the currently booted device.

You may also want to look at Xcode 6 - Launch simulator from command line for information about how to launch the iOS Simulator app and have it start a specific device.

Guillaume Algis
  • 10,705
  • 6
  • 44
  • 72
Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • Thanks bud. I don't know why but StackOverflow didn't notify me there was an answer. I'll try it today and respond. Thanks again. – Stoutie Oct 14 '14 at 14:36
  • Also, can you add a description of what this command is actually doing? These commands are completely foreign to me. – Stoutie Oct 14 '14 at 14:36
  • @stoutie Run 'xcrun simctl help' for additional help on the simctl command. The xcrun command is a wrapper to execute simctl from within your currently selected Xcode.app. – Jeremy Huddleston Sequoia Oct 14 '14 at 15:05
  • I can't get it to work. I'm not sure from the list what the device id is? https://gist.github.com/jehoshua02/28159e9edaa53177904e#file-xcrun_simctl_list-md – Stoutie Oct 14 '14 at 15:39
  • 3
    You can just pass the flag: **booted** to use the current simulator so you have to look for it's UDID. Example: ```xcrun simctl openurl booted http://www.google.com``` – Marcio Klepacz Aug 04 '15 at 15:40
  • Yep. That was added a few months ago :) – Jeremy Huddleston Sequoia Aug 04 '15 at 20:22