一、Xcode允许我们使用xcrun命令运行模拟器
1、列出你安装的所有可用的设备
xcrun instruments -s
终端显示结果:
Apple TV (11.2) [E08E425C-ACE2-49EE-9451-2F8DE1606B44] (Simulator)
Apple TV 4K (11.2) [5F7F618E-755D-4FB5-B1D2-C723BA3B7613] (Simulator)
Apple TV 4K (at 1080p) (11.2) [557BB6AF-5F1F-4C62-9414-A21EB4289CF1] (Simulator)
Apple Watch - 38mm (4.2) [C7815581-8534-4E6C-B107-F1495A4B9068] (Simulator)
Apple Watch - 42mm (4.2) [9C77DCFB-2D4B-4A51-B426-898BF3AED63D] (Simulator)
iPad (5th generation) (11.2) [2B4B20F7-5399-41EE-ADB6-82441DDA7DD6] (Simulator)
iPad 2 (8.1) [9CC3E76E-790D-47E2-83B0-08549DEA5B79] (Simulator)
iPad Air (11.2) [32324B01-514C-4364-9D14-AA6AA3AA6667] (Simulator)
iPad Air (8.1) [6A456359-C74D-4AF7-85D0-8BFC06D58DDE] (Simulator)
iPad Air 2 (11.2) [8FB3BFC5-C8F3-4D17-9888-13C3D130672F] (Simulator)
iPad Pro (10.5-inch) (11.2) [D966E55E-2E7C-42EA-8DEA-B917EC40558F] (Simulator)
iPad Pro (12.9-inch) (11.2) [901BB588-BD07-4937-9653-8756A05E3824] (Simulator)
iPad Pro (12.9-inch) (2nd generation) (11.2) [55827A7E-569C-42E8-9492-989C141ED55C] (Simulator)
iPad Pro (9.7-inch) (11.2) [A705DB78-8ED8-4137-BEF9-9B5CFF9229BC] (Simulator)
iPad Retina (8.1) [1A2472B0-B137-4991-9222-990FDB6F9544] (Simulator)
iPhone 4s (8.1) [745200F8-60B8-486B-B3AC-DD59F2DBD997] (Simulator)
iPhone 5 (8.1) [C66205E1-901C-4AB2-A33E-EBE255223A6A] (Simulator)
iPhone 5s (11.2) [D28C05B3-75D0-4A3D-A638-E57E38118300] (Simulator)
iPhone 5s (8.1) [8E92EC49-AD5E-4DAB-8BDC-447CA0388D01] (Simulator)
iPhone 6 (11.2) [0DCE32BE-66AE-482E-A090-D661CB8DD8A9] (Simulator)
iPhone 6 (8.1) [61AA0391-3E92-4FD0-AE44-25F5A5FC5EFD] (Simulator)
iPhone 6 Plus (11.2) [7CF30729-2936-420C-AC28-3071A803D833] (Simulator)
iPhone 6 Plus (8.1) [001623D8-9BF2-4B6E-9721-35220CF3546C] (Simulator)
iPhone 6s (11.2) [E78DEBD1-828A-4048-8683-BD5A49AB908B] (Simulator)
iPhone 6s Plus (11.2) [709F1869-E443-4C4D-9B78-0612FBB72E95] (Simulator)
iPhone 7 (11.2) [7AD29C08-152D-4995-9B33-4C13918555C8] (Simulator)
iPhone 7 (11.2) + Apple Watch Series 2 - 38mm (4.2) [56EA998A-D360-4771-B89D-C1FB051713AC] (Simulator)
iPhone 7 Plus (11.2) [A0BCF261-BEA8-4EBC-A565-3773E5B7733E] (Simulator)
iPhone 7 Plus (11.2) + Apple Watch Series 2 - 42mm (4.2) [013DEEB7-05FA-4E74-8FFD-069DBC6AB0C4] (Simulator)
iPhone 8 (11.2) [39E670F7-F9B0-4A1F-92E7-202EED62E66A] (Simulator)
iPhone 8 (11.2) + Apple Watch Series 3 - 38mm (4.2) [02C9E3B3-9846-4AD0-9890-B2B840811BC9] (Simulator)
iPhone 8 Plus (11.2) [18B8751C-097C-427C-9DB8-BF59FB3C1D7E] (Simulator)
iPhone 8 Plus (11.2) + Apple Watch Series 3 - 42mm (4.2) [E381F8A1-54E9-4428-BE4A-7011902C5D69] (Simulator)
iPhone SE (11.2) [D8ACFB1F-6678-4014-8993-72050939481D] (Simulator)
iPhone X (11.2) [1346D0CB-C0A7-40F9-BB8B-C095B736C696] (Simulator)
2、开启指定模拟器(上面的列表就是可用模拟器名称)
xcrun instruments -w "iPhone 8 (11.2)"
二、使用的Xcode的simctl命令来控制模拟器
1、安装指定的app
xcrun simctl install booted <app路径>
2、运行指定的app (com.example.app)
xcrun simctl launch booted <app identifier>
3、卸载指定的应用
xcrun simctl uninstall booted <app identifier>