How can I launch the iOS Simulator from Terminal?

前端 未结 8 663
梦如初夏
梦如初夏 2020-12-07 10:12

I can build using the Xcode command line tools, is there any way I can actually run the application using them? (E.g. the equivalent to pressing Cmd+R in Xcode)

相关标签:
8条回答
  • 2020-12-07 10:48

    Type this in terminal: open -a Simulator.app

    0 讨论(0)
  • 2020-12-07 10:48

    This is the answer your looking for:

    • 1.open terminal
      1. xcrun simctl list
      2. get udid of the device you want to launch
      3. Paste this in the terminal
      4. open -a Simulator --args -CurrentDeviceUDID 0566AC33-9B91-2DR2-B5BB-C916D3BA8MD3
    0 讨论(0)
  • 2020-12-07 10:55

    As of this date it will work:

    open -a simulator 
    

    it is the easiest way.

    0 讨论(0)
  • 2020-12-07 11:05

    # Update In the new Xcode update, supported simulators are from iPhone 8 onwards

    0 讨论(0)
  • 2020-12-07 11:09

    First decide what device you want to use:

    xcrun simctl list
    

    This will give you a list of devices:

    -- iOS 9.0 --
        iPhone 4s (56632E02-650E-4C24-AAF4-5557FB1B8EB2) (Shutdown)
        iPhone 5 (ACD4DB7B-9FC9-49D5-B06B-BA5D5E2F5165) (Shutdown)
        iPhone 5s (A8358B76-AD67-4571-9EB7-FFF4D0AC029E) (Shutdown)
        iPhone 6 (1D46E980-C127-4814-A1E2-5BE47F6A15ED) (Shutdown)
        iPhone 6 Plus (FD9F726E-453A-4A4C-9460-A6C332AB140B) (Shutdown)
    

    Choose the ID (eg. FD9F726E-453A-4A4C-9460-A6C332AB140B) you want (you can create your own device using xcrun simctl create if you want).

    Boot the simulator with that device (replacing YOUR-DEVICE-ID with the ID)

    /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <YOUR-DEVICE-ID>
    

    Now you should be able to use simctl to install and launch commands.

    xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
    xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>
    

    xcrun simctl help for more details. Note that booting a device using simctl does not currently (Xcode 7.2) allow you to do anything else with that device such as launch or install applications. You need to launch the device in the simulator to actually do anything interesting. Also, you cannot delete a device that is in use by the simulator, so you will have to quit/kill the simulator before attempting to delete anything.

    0 讨论(0)
  • 2020-12-07 11:12
    open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/
    
    0 讨论(0)
提交回复
热议问题