XCRUN-iOS模拟器管理工具

xcrun类似安卓系统下的ADB命令。

了解这些相关工具,能够给测试的执行、开展带来很多便利条件。

苹果提供了一个命令行工具来与iOS模拟器进行交互。这与安卓的adb命令非常相似。我们可以在Applications/Xcode.app/Contents/Developer/usr/bin/simctl路径找到。

这是XCode内置的命令,所以在使用的时候要在该命令前面加上xcrun。


---------------------

常用命令:

列出可用模拟器

$ xcrun simctl list

列出正在运行的模拟器

$ xcrun simctl list devices

让模拟器打开网页

xcrun simctl openurl booted "https://reg.163.com"

同样我们可以通过URL Scheme方式一样打开一个app

xcrun simctl openurl booted "com.netease.preciousMetal.dev"

关闭、重置、启动

$ xcrun simctl shutdown booted

$ xcrun simctl erase "60613B62-A648-4149-BE64-9E6CBD5DBD30"

xcrun simctl help

可以看到相关命令用法:

Subcommands:

create              Create a new device.

clone              Clone an existing device.

upgrade            Upgrade a device to a newer runtime.

delete              Delete a device or all unavailable devices.

pair                Create a new watch and phone pair.

unpair              Unpair a watch and phone pair.

pair_activate      Set a given pair as active.

erase              Erase a device's contents and settings.

boot                Boot a device.

shutdown            Shutdown a device.

rename              Rename a device.

getenv              Print an environment variable from a running device.

openurl            Open a URL in a device.

addmedia            Add photos, live photos, videos, or contacts to the library of a device.

install            Install an app on a device.

uninstall          Uninstall an app from a device.

get_app_container  Print the path of the installed app's container

launch              Launch an application by identifier on a device.

terminate          Terminate an application by identifier on a device.

spawn              Spawn a process by executing a given executable on a device.

list                List available devices, device types, runtimes, or device pairs.

icloud_sync        Trigger iCloud sync on a device.

pbsync              Sync the pasteboard content from one pasteboard to another.

pbcopy              Copy standard input onto the device pasteboard.

pbpaste            Print the contents of the device's pasteboard to standard output.

help                Prints the usage for a given subcommand.

io                  Set up a device IO operation.

diagnose            Collect diagnostic information and logs.

logverbose          enable or disable verbose logging for a device



多模拟器同时check视觉效果

如果有视觉问题,需要确认在各种屏幕上的显示效果,可以采取该方法。

首先使用xcrun  simctl list devices查找需要的机型的UUID

UUID 是 通用唯一识别码(Universally Unique Identifier)的缩写

找到iOS 12下面代表各个屏幕尺寸机型的UUID


uuid

实验过程:

#1.首先打开模拟器应用

open "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/"

#2.然后启动待测试的模拟器(分别对应截图中的UUID标志符字符串)

xcrun simctl boot "EC7372BD-DAD0-486E-9D15-61521B5837A4"

xcrun simctl boot "84150271-D363-4B47-8AA9-E2635CF55F3B"

xcrun simctl boot "747E2529-2FC3-4CD0-8AE1-E6F875EC6A31"

xcrun simctl boot "697BF2CA5-7981-4E0F-A532-EC543001413C"

xcrun simctl boot "5D17BD6F-C080-4898-A1D1-855F0C890937"

xcrun simctl boot "94B0F54A-BB47-496F-A8F7-746F581AEF73"

#3.在模拟器上安装待测试的app,下面的变量其实是Xcode的环境变量,在run script中直接使用即可

xcrun simctl install "EC7372BD-DAD0-486E-9D15-61521B5837A4" "/Users/lipeng/Desktop/DevFiles/PreciousMetalsDev.app"

xcrun simctl install "84150271-D363-4B47-8AA9-E2635CF55F3B" "/Users/lipeng/Desktop/DevFiles/PreciousMetalsDev.app"

xcrun simctl install "747E2529-2FC3-4CD0-8AE1-E6F875EC6A31" "/Users/lipeng/Desktop/DevFiles/PreciousMetalsDev.app"

xcrun simctl install "697BF2CA5-7981-4E0F-A532-EC543001413C" "/Users/lipeng/Desktop/DevFiles/PreciousMetalsDev.app"

xcrun simctl install "5D17BD6F-C080-4898-A1D1-855F0C890937" "/Users/lipeng/Desktop/DevFiles/PreciousMetalsDev.app"

xcrun simctl install "94B0F54A-BB47-496F-A8F7-746F581AEF73" "/Users/lipeng/Desktop/DevFiles/PreciousMetalsDev.app"

#4.最后打开应用

xcrun simctl launch "EC7372BD-DAD0-486E-9D15-61521B5837A4" "com.netease.gold.dev"

xcrun simctl launch "84150271-D363-4B47-8AA9-E2635CF55F3B" "com.netease.gold.dev"

xcrun simctl launch "747E2529-2FC3-4CD0-8AE1-E6F875EC6A31" "com.netease.gold.dev"

xcrun simctl launch "697BF2CA5-7981-4E0F-A532-EC543001413C" "com.netease.gold.dev"

xcrun simctl launch "5D17BD6F-C080-4898-A1D1-855F0C890937" "com.netease.gold.dev"

xcrun simctl launch "694B0F54A-BB47-496F-A8F7-746F581AEF73" "com.netease.gold.dev"

---------------------

可能要求性能比较强,哈哈哈,15寸MacBook走起。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 叮铃铃,叮铃铃,尖锐而又急促的手机铃声划破夜空的寂静,把我从发呆的状态中,硬生生的拉到现实世界之中。 这几天的状态...
    豆三叶阅读 357评论 3 6
  • 1.在进行json解析之前需要下载jar包。这里推荐使用google-gson 3.3-3 【分析】我们通过Gso...
    好大一只鹏阅读 635评论 0 0
  • 这个世界充满着矛盾重重又无可调和的情感,山巅壑底之间没有桥梁,爱与恨总是各执一词。 ——《蝴蝶的叫喊》薇诺拉
    添加无糖阅读 199评论 0 0