如何从终端启动 iOS 模拟器? [英] How can I launch the iOS Simulator from Terminal?

查看:27
本文介绍了如何从终端启动 iOS 模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 Xcode 命令行工具进行构建,有什么方法可以使用它们实际运行应用程序吗?(例如,相当于在 Xcode 中按 Cmd+R)

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)

推荐答案

首先决定你要使用的设备:

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)

选择您想要的 ID(例如 FD9F726E-453A-4A4C-9460-A6C332AB140B)(如果需要,您可以使用 xcrun simctl create 创建自己的设备).

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 替换您的设备 ID)

Boot the simulator with that device (replacing YOUR-DEVICE-ID with the ID)

/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <YOUR-DEVICE-ID>

现在您应该可以使用 simctl 来安装和启动命令了.

Now you should be able to use simctl to install and launch commands.

xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>

xcrun simctl help 了解更多详情.请注意,使用 simctl 引导设备当前 (Xcode 7.2) 不允许您对该设备执行任何其他操作,例如启动或安装应用程序.您需要在模拟器中启动设备才能真正做任何有趣的事情.此外,您无法删除模拟器正在使用的设备,因此您必须在尝试删除任何内容之前退出/终止模拟器.

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.

这篇关于如何从终端启动 iOS 模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆