xcrun simctl listは、デバイス・デバイスタイプ・ランタイム・ペアの一覧を表示するサブコマンドである。
種類の指定や検索語での絞り込み、JSON形式での出力に対応している。
基本的な使い方
list [devices|devicetypes|runtimes|pairs] [<search term>|available]の形式で実行する。
種類を省略すると、デバイス・デバイスタイプ・ランタイム・ペアのすべてが順に表示される。
$ xcrun simctl list runtimes
== Runtimes ==
iOS 17.5 (17.5 - 21F79) - com.apple.CoreSimulator.SimRuntime.iOS-17-5
iOS 18.3 (18.3.1 - 22D8075) - com.apple.CoreSimulator.SimRuntime.iOS-18-3
...
検索語で結果を絞り込める
種類の後ろに検索語を指定すると、大文字と小文字を区別しない部分一致で絞り込める。
$ xcrun simctl list devicetypes watch
== Device Types ==
Apple Watch Series 12 (46mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-12-46mm)
Apple Watch Series 12 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-12-42mm)
...
availableはdevicetypesには効かない
ヘルプには「availableという検索語を使うと、利用可能な項目だけに絞り込める」と書かれている。
runtimesやdevicesではその通りに動作し、インストール済み・利用可能な項目がそのまま表示される。
$ xcrun simctl list runtimes available
== Runtimes ==
iOS 17.5 (17.5 - 21F79) - com.apple.CoreSimulator.SimRuntime.iOS-17-5
...
一方devicetypesに対してavailableを指定すると、常に0件になる。
$ xcrun simctl list devicetypes available
== Device Types ==
devicetypesは「このMacで作成できるデバイスの種類」の定義一覧であり、個々のデバイスタイプ自体に「利用可能かどうか」という状態を持たないため、availableによる絞り込みの対象にならないとみられる。
-jでJSON形式に、-eでスラッシュのエスケープを解除できる
-jを付けるとJSON形式で出力できる。
既定ではパス中の/が\/にエスケープされるが、-eを付けるとエスケープなしの見慣れた形式になる。
$ xcrun simctl list -j runtimes | grep bundlePath
"bundlePath" : "\/Library\/Developer\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 15 Pro.simdevicetype",
$ xcrun simctl list -j -e runtimes | grep bundlePath
"bundlePath" : "/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone 15 Pro.simdevicetype",
--json-output・--json-fdでJSONを標準出力ではなく別の場所に書き出せる
--json-output=<path>を使うと、JSONを標準出力に出さずファイルへ直接書き出せる。
$ xcrun simctl list -j --json-output=./list-output.json devicetypes
(標準出力には何も表示されない)
$ head -c 80 ./list-output.json
{
"devicetypes" : [
{
"productFamily" : "iPhone",
--json-fd=<fd>を使うと、あらかじめシェル側で開いておいたファイルディスクリプタへ直接書き出すこともできる。
$ exec 5>./list-fd-output.json
$ xcrun simctl list -j --json-fd=5 devicetypes
$ exec 5>&-
シェルスクリプトの中で、標準出力を他の用途に使いながらJSON結果だけ別途受け取りたい場合に活用できる。
-vでビルド番号やランタイムのパスも表示できる
-vを付けると、ランタイムのセクション見出しにビルド番号とランタイム本体のパスが追加で表示される。
$ xcrun simctl list devices "iPhone 17"
== Devices ==
...
-- iOS 26.1 --
iPhone 17 (EE5F81DC-7C94-4DB7-BFD2-1C974A023ED0) (Shutdown)
...
$ xcrun simctl list -v devices "iPhone 17"
== Devices ==
...
-- iOS 26.1 (23B86) [/Library/Developer/CoreSimulator/Volumes/iOS_23B86/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 26.1.simruntime] --
iPhone 17 (EE5F81DC-7C94-4DB7-BFD2-1C974A023ED0) (Shutdown)
...
インストール済みの他のランタイムに対応する見出し行(該当デバイスがないため空)は...で省略している。
