1、查看mac上所有模拟器列表
instruments -s
电脑输出
Apple TV (11.2) [F0EDF0AC-2B09-4FE7-A09F-C00D2A110AB0] (Simulator)
Apple TV 4K (11.2) [E757B45D-DEDC-4DA8-9EE3-8FC2895E3B6D] (Simulator)
Apple TV 4K (at 1080p) (11.2) [584B3C28-0CB5-48E8-840D-81D7B016D751] (Simulator)
Apple Watch - 38mm (4.2) [96A9B895-6F3B-43C2-8615-CBD73215D809] (Simulator)
Apple Watch - 42mm (4.2) [3A6D5324-4DD9-4A58-869F-DC216E4305E1] (Simulator)
iPad (5th generation) (11.2) [755A9702-9F17-49B5-BC32-1D3FEFACA762] (Simulator)
iPad Air (11.2) [B567F820-7D1D-4F63-85A5-A95AEE77A259] (Simulator)
iPad Air 2 (11.2) [37A14650-E163-4572-8ABC-BF50E52AA90E] (Simulator)
iPad Pro (10.5-inch) (11.2) [12EA9912-1A09-4F5A-B6DE-5C6EC57818A4] (Simulator)
iPad Pro (12.9-inch) (11.2) [57BF24D8-26BC-4FB1-B686-D02BFF8C6590] (Simulator)
iPad Pro (12.9-inch) (2nd generation) (11.2) [2BC3A285-F3E0-4148-91C8-1C0702C8CA17] (Simulator)
iPad Pro (9.7-inch) (11.2) [279075C4-9EF3-43AC-A3A0-CB46DFF06761] (Simulator)
iPhone 5s (11.2) [823F375A-33B3-441D-8143-DBD38D65BC63] (Simulator)
iPhone 6 (11.2) [FD17D78C-23AA-4B8C-964A-51B0BC174FA7] (Simulator)
iPhone 6 Plus (11.2) [BD2870F8-1975-44FB-8A22-E5D2450BF9CA] (Simulator)
iPhone 6s (11.2) [01FB768A-5924-45F4-8EAA-49F61E4C2DA3] (Simulator)
iPhone 6s Plus (11.2) [21451403-E647-4EAA-A903-6A75D45B5A3A] (Simulator)
iPhone 7 (11.2) [3622986D-7C46-4D65-9D98-F193EC9BD2C2] (Simulator)
iPhone 7 (11.2) + Apple Watch Series 2 - 38mm (4.2) [BFC72F28-0275-414E-A99D-B92CE0770DD5] (Simulator)
iPhone 7 Plus (11.2) [05EB0E15-0D15-48BC-A44A-83161ECC0218] (Simulator)
iPhone 7 Plus (11.2) + Apple Watch Series 2 - 42mm (4.2) [30A3772F-04F0-45BE-BD07-B0880A9189F8] (Simulator)
iPhone 8 (11.2) [945D8655-AF72-4738-A850-6001365F2103] (Simulator)
iPhone 8 (11.2) + Apple Watch Series 3 - 38mm (4.2) [F52EA681-3A49-4977-A6B8-2E6567529E58] (Simulator)
iPhone 8 Plus (11.2) [CBC7EC4B-68FB-4382-B48A-C2FDA32930EA] (Simulator)
iPhone 8 Plus (11.2) + Apple Watch Series 3 - 42mm (4.2) [CB778B9A-8CD8-4F40-9436-C5ED71F3568A] (Simulator)
iPhone SE (11.2) [D69AEE8A-7C79-4E13-B2B8-4920AC9F0214] (Simulator)
iPhone X (11.2) [E027FC13-3DA6-4A6D-8FE1-39C8FC1E6236] (Simulator)
2、启动指定的模拟器
xcrun instruments -w "Apple TV (11.2) [F0EDF0AC-2B09-4FE7-A09F-C00D2A110AB0] (Simulator)"
3、xcodebuild生成的.app安装到模拟器中
xcrun simctl install booted <xxx.app> 其中,xxx.app 为这个ipa包的路径
4、从模拟器中启动指定的app
xcrun simctl launch booted 'XXXXX' --xxxxx为app的bundle的id
5、从模拟器中删除制定的app
xcrun simctl uninstall booted 'XXXXX' --xxxxx为app的bundle的id
6、对模拟器的操作进行录屏
xcrun simctl io booted recordVideo --type=mp4 path --path 为录屏的地址
7、通过 Bundle ID 获取 app 的 info 信息
xcrun simctl appinfo booted 'XXXXX' --xxxxx为app的bundle的id