无论如何可以通过终端在 mac 中获取启动模拟器的 UDID

Is there anyway to get the UDID of a booted simulator in mac via terminal

尝试为不同的 Ipad 模拟器启动 Appium 服务器,但是当我使用以下命令时

xcrun simctl list | egrep '(Booted)'

我得到了引导模拟器的完整细节

iPad (5th generation) (1D9E3D9C-7715-4742-A9DC-6096BCE95B64) (Booted) 

有什么方法可以只获取已启动的模拟器的 UDID

也许可以尝试使用 awk 或等价物来获取 UDID 信息:

xcrun simctl list | awk -F'[()]' '/(Booted)/ { print  }'

您可能需要调整输出字段的数字(因此可能不是 </code>,而是 <code>,等等)

这对我有用:

xcrun simctl list devices | grep "(Booted)" | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})"