I want to launch iPhone simulator from command line.
until now I have been using the below command
/Applications/Xcode.app/Contents/Developer
Run this command. The app will be restarted followed by changes. No need to rebuild it again.
ios-sim "launch" "/Library/WebServer/Documents/testapp/build/iphone/build/Debug-iphonesimulator/test.app" "--devicetypeid" "iPad-2" "--exit";
For devicetypeid list:
ios-sim showdevicetypes
Verified in Xcode 9.4.1
Device list in a REALLY NICE FORMAT:
~/Library/Developer/CoreSimulator/Devices/device_set.plist
Root
DefaultDevices
com.apple.CoreSimulator.SimRuntime.iOS-8-4
com.apple.CoreSimulator.SimDeviceType.iPad-Retina : AB335FAF-E3E3-4AE9-A0AF-D1C6AEB5FBD4
Then you want to run (open) your Simulator app and make sure that a new instance of the app is launched.
The app is here:
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
And the format you'd use is like this:
open -n -a <SimulatorPath> --args -CurrentDeviceUDID <SimDeviceTypeUDID>
So, if I wanted to launch the Simulator above, I'd do this.
open -n -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID AB335FAF-E3E3-4AE9-A0AF-D1C6AEB5FBD4
Hot damn! I just tested it and it works on Mac OS 10.11.6. Now the next trick is telling the Simulator to open our installed app. I'm not there yet. Hope this helps. Thanks to https://stackoverflow.com/users/726106/jeremy-huddleston-sequoia for his detailed explanation.