我想按以下格式列出可用的 ios 模拟器(iOS 版本应取自 JSON 密钥)
{
"name": "iPhone 5s (11.4)",
"udid": "FB6B3F7F-E6CD-4F64-8EC4-6C07C86A25C8"
}
{
"name": "iPhone 6 Plus (11.4)",
"udid": "768AE0B3-F77A-4DF4-8198-74CB2D598D19"
}
...
{
"name": "iPad Air (11.4)",
"udid": "396C0E3A-7DFD-41BD-9E05-28A27E6BB4AB"
}
{
"name": "iPad Air 2 (11.4)",
"udid": "1AD4AC1A-B45B-4869-9778-B5572D4CE031"
}
...
{
"name": "iPhone 8 (13.2)",
"udid": "71E02A7B-BCBB-45D8-8638-E5381B420406"
}
{
"name": "iPhone 8 Plus (13.2)",
"udid": "D3333C55-2D0A-4999-B6D2-450C637C9248"
}
...
{
"name": "iPad (7th generation) (13.2)",
"udid": "0543121E-86DC-4BC9-933F-60AA31D219CD"
}
{
"name": "iPad Pro (11-inch) (13.2)",
"udid": "1979F272-E938-45AA-9717-A5228AF6EBF1"
}
...
我试过这样的东西
xcrun simctl list --json devices available | jq '.devices | with_entries(select(.key|contains("com.apple.CoreSimulator.SimRuntime.iOS")))'
但我无法实现其余的jq操作以实现预期的格式。
输出xcrun simctl list --json devices available
如下
{
"devices" : {
"com.apple.CoreSimulator.SimRuntime.iOS-11-4" : [
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 5s",
"udid" : "FB6B3F7F-E6CD-4F64-8EC4-6C07C86A25C8"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6 Plus",
"udid" : "768AE0B3-F77A-4DF4-8198-74CB2D598D19"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6",
"udid" : "A02B7489-0D21-4317-AF01-94604C910ACB"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6s",
"udid" : "8482548E-3A1A-4EE8-833A-C45B59F87061"
},
{
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone 6s Plus",
"udid" : "12D1E272-48EB-4C26-8F64-201C8C2375ED"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone SE",
"udid" : "558C8C2A-C993-4728-8847-06B9353F234D"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 7",
"udid" : "D43EF2BC-7298-4900-B94F-4C72C09A1709"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 7 Plus",
"udid" : "3F6D7F10-84EA-49C0-ADFD-58F80125BE18"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8",
"udid" : "04DD5864-D2BA-42D9-AC30-28C2E8FB553A"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8 Plus",
"udid" : "E37DFF3B-2065-4116-9BA9-2A5DEB588E40"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "3A5FA651-64A9-4207-A8EA-9005907FB1DC"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air",
"udid" : "396C0E3A-7DFD-41BD-9E05-28A27E6BB4AB"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air 2",
"udid" : "1AD4AC1A-B45B-4869-9778-B5572D4CE031"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (9.7-inch)",
"udid" : "9050DF70-51B3-4D7D-8188-D8CE7309AC15"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch)",
"udid" : "551D5F5A-FC3E-4F7A-B19C-F6E05486D7F9"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad (5th generation)",
"udid" : "BBB67188-C866-4314-BD14-5969E89D327F"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch) (2nd generation)",
"udid" : "861D5117-DB9C-4175-A3E9-6A61BBD6EEC8"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (10.5-inch)",
"udid" : "6677E587-25F1-48B2-B13E-1F7D7BCAB8E8"
}
],
"com.apple.CoreSimulator.SimRuntime.watchOS-6-0" : [
],
"com.apple.CoreSimulator.SimRuntime.iOS-13-1" : [
],
"com.apple.CoreSimulator.SimRuntime.tvOS-13-0" : [
],
"com.apple.CoreSimulator.SimRuntime.watchOS-6-1" : [
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 4 - 40mm",
"udid" : "D3D274E3-E139-4703-A8E5-344A68E847EB"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 4 - 44mm",
"udid" : "DFB29187-06DF-4741-A220-59AF0EB93CD5"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 5 - 40mm",
"udid" : "2C61EF40-69B0-4427-BF5F-D53871E38202"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 5 - 44mm",
"udid" : "BFF68412-CED6-4331-932E-D0E266DF0729"
}
],
"com.apple.CoreSimulator.SimRuntime.tvOS-13-2" : [
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV",
"udid" : "82076106-2C88-49E9-B294-4710C185FEA0"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV 4K",
"udid" : "9E125B78-669C-4AA2-A896-B2ED594B25D5"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV 4K (at 1080p)",
"udid" : "25491FB4-8C64-42A9-9DC4-91D1F2969CF0"
}
],
"com.apple.CoreSimulator.SimRuntime.iOS-13-2" : [
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8",
"udid" : "71E02A7B-BCBB-45D8-8638-E5381B420406"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8 Plus",
"udid" : "D3333C55-2D0A-4999-B6D2-450C637C9248"
},
{
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone 11",
"udid" : "A6B7C24D-FDDE-403D-AEE6-0ADA25D681F9"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 11 Pro",
"udid" : "E88DCE74-BF13-45A6-B0E8-2436175765CD"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 11 Pro Max",
"udid" : "925FE40D-3FBC-4E60-801C-A44DB3CBF866"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (9.7-inch)",
"udid" : "429D0104-D49D-4454-AA59-428F0A7B35BC"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad (7th generation)",
"udid" : "0543121E-86DC-4BC9-933F-60AA31D219CD"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (11-inch)",
"udid" : "1979F272-E938-45AA-9717-A5228AF6EBF1"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch) (3rd generation)",
"udid" : "EBA9C68B-0162-4FBB-B104-32BD5B1C3512"
},
{
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air (3rd generation)",
"udid" : "8C26E739-659F-4631-A607-8C34C0DA2E5F"
}
]
}
}
如何按预期格式列出可用的 ios 模拟器?