如何从终端启动 iOS 模拟器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31179706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I launch the iOS Simulator from Terminal?
提问by Alex Chesters
I can build using the Xcode command line tools, is there any way I can actually run the application using them? (E.g. the equivalent to pressing Cmd+R in Xcode)
我可以使用 Xcode 命令行工具进行构建,有什么方法可以使用它们实际运行应用程序吗?(例如相当于在 Xcode 中按 Cmd+R)
回答by Mathioli Ramalingam
Type this in terminal:
open -a Simulator.app
在终端中输入:
open -a Simulator.app
回答by dmaclach
First decide what device you want to use:
首先确定您要使用的设备:
xcrun simctl list
This will give you a list of devices:
这将为您提供设备列表:
-- iOS 9.0 --
iPhone 4s (56632E02-650E-4C24-AAF4-5557FB1B8EB2) (Shutdown)
iPhone 5 (ACD4DB7B-9FC9-49D5-B06B-BA5D5E2F5165) (Shutdown)
iPhone 5s (A8358B76-AD67-4571-9EB7-FFF4D0AC029E) (Shutdown)
iPhone 6 (1D46E980-C127-4814-A1E2-5BE47F6A15ED) (Shutdown)
iPhone 6 Plus (FD9F726E-453A-4A4C-9460-A6C332AB140B) (Shutdown)
Choose the ID (eg. FD9F726E-453A-4A4C-9460-A6C332AB140B) you want (you can create your own device using xcrun simctl create
if you want).
选择您想要的 ID(例如 FD9F726E-453A-4A4C-9460-A6C332AB140B)(您可以根据需要创建自己的设备xcrun simctl create
)。
Boot the simulator with that device (replacing YOUR-DEVICE-ID with the ID)
使用该设备启动模拟器(用 ID 替换 YOUR-DEVICE-ID)
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <YOUR-DEVICE-ID>
Now you should be able to use simctl to install and launch commands.
现在您应该能够使用 simctl 来安装和启动命令。
xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>
xcrun simctl help
for more details. Note that booting a device using simctl does not currently (Xcode 7.2) allow you to do anything else with that device such as launch or install applications. You need to launch the device in the simulator to actually do anything interesting. Also, you cannot delete a device that is in use by the simulator, so you will have to quit/kill the simulator before attempting to delete anything.
xcrun simctl help
更多细节。请注意,使用 simctl 启动设备当前 (Xcode 7.2) 不允许您对该设备执行任何其他操作,例如启动或安装应用程序。您需要在模拟器中启动设备才能真正做任何有趣的事情。此外,您无法删除模拟器正在使用的设备,因此您必须在尝试删除任何内容之前退出/终止模拟器。
回答by Benjith Kizhisseri
open -a simulator
it worked for me
它对我有用
回答by AlejandroJSR7
Open your terminal and paste this code:
打开终端并粘贴以下代码:
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
回答by Llogari Casas
open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/
回答by Adrian Jimenez
This is the answer your looking for:
这是您正在寻找的答案:
- 1.open terminal
- xcrun simctl list
- get udid of the device you want to launch
- Paste this in the terminal
- open -a Simulator --args -CurrentDeviceUDID 0566AC33-9B91-2DR2-B5BB-C916D3BA8MD3
- 1.打开终端
- xcrun simctl 列表
- 获取您要启动的设备的 udid
- 将此粘贴到终端中
- 打开 -a 模拟器 --args -CurrentDeviceUDID 0566AC33-9B91-2DR2-B5BB-C916D3BA8MD3
回答by Dionisio Malteso
# UpdateIn the new Xcode update, supported simulators are from iPhone 8onwards
# 更新在新的 Xcode 更新中,支持的模拟器从iPhone 8开始