How to list devices available to Xcode
Using xcodebuild, or better xcrun xcodebuild we can do things such as running tests from the terminal.
xcrun xcodebuild \
-workspace "Coconut.workspace" \
-scheme "Coconut" \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
test
But what to write in the -destination parameter? How do we know the available devices that can be used as parameter?
The instruments cli tool from Apple has an answer to that.
instrumenst “runs an Instrument template from the command line”, and one of the available options to pass is is -s devices, to “show list of known devices, and then exit”.
instruments -s devices
Known Devices:
Gio’s MacBook Pro [<uuid>]
Gio's iPhone 6 (8.2) [<uuid>]
Resizable iPad (8.2 Simulator) [<uuid>]
Resizable iPhone (8.2 Simulator) [<uuid>]
iPad 2 (8.2 Simulator) [<uuid>]
iPad Air (8.2 Simulator) [<uuid>]
iPad Retina (8.2 Simulator) [<uuid>]
iPhone 4s (8.2 Simulator) [<uuid>]
iPhone 5 (8.2 Simulator) [<uuid>]
iPhone 5s (8.2 Simulator) [<uuid>]
iPhone 6 (8.2 Simulator) [<uuid>]
iPhone 6 Plus (8.2 Simulator) [<uuid>]
There you go, here’s the list of known devices to the computer, and any of can be used as the parameters for the -destination
argument.
查看正在运行的模拟器的udid: xcrun simctl list devices | grep Booted
启动某个模拟器上的某个应用:xcrun simctl launch 319ADEF3-E9E9-434C-B520-B4E781DB2731 com.***.iphoneclientdev