简体   繁体   English

如何检查iPhone模拟器的设备ID?

[英]How to check device id of iPhone simulator?

I want to check device id for my iPhone simulator application.我想检查我的 iPhone 模拟器应用程序的设备 ID。 But not using codebase.但不使用代码库。 I know the way how to do with codebase, using UIDevice instance.我知道如何使用 UIDevice 实例处理代码库。

Is there any way to find device id without using codebase?有没有办法在不使用代码库的情况下找到设备 ID?

试试这个

instruments -s devices

EDIT: See other answers for the newer ways to view UDIDs for CoreSimulator -based simulators.编辑:有关查看基于CoreSimulator的模拟器的 UDID 的较新方法的其他答案。

  1. instruments -s devices
  2. xcrun simctl list
  3. From Xcode: Window -> Devices and Simulators -> Simulators.从 Xcode:窗口 -> 设备和模拟器 -> 模拟器。 The Identifier value is the UDID. Identifier值是 UDID。

From 2011:从 2011 年开始:

Is the iPhone Simulator UDID unique for each installed instance? 每个安装的实例的 iPhone 模拟器 UDID 是唯一的吗?

This answer should be what you want.这个答案应该是你想要的。 Look at System Profiler on your mac and the id is there.在您的 Mac 上查看 System Profiler,ID 就在那里。 I just tested on my machine and the IDs match.我刚刚在我的机器上测试过,ID 匹配。

This is the exact Terminal command you can enter to view it:这是您可以输入以查看它的确切终端命令:

system_profiler SPHardwareDataType

As so often, there is a Xcode terminal tool for that (part of the Xcode tools ) see xcrun manpage通常,有一个Xcode 终端工具Xcode 工具的一部分),请参阅xcrun联机帮助页

xcrun simctl list | egrep '(Booted)'

lists only all booted (could be more than one) Simulators (remove | egrep '(Booted)' to see them all).仅列出所有已启动的(可能不止一个)模拟器(删除| egrep '(Booted)'以查看全部)。

UIID results like UIID 结果如

 iPhone 6 Plus (AAAABD40-9DE6-44B7-A4EA-B34ABCDEFCA6) (Booted)

you can then lookup a folder in ~/Library/Developer/CoreSimulator/Devices on your Mac and find all the "belongings" of that particular Simulator然后,您可以在 Mac 上的~/Library/Developer/CoreSimulator/Devices查找文件夹,并找到该特定模拟器的所有“所有物”

You can also retrieve the same UDID, labeled as "Identifier".您还可以检索相同的 UDID,标记为“标识符”。 In the Xcode Window menu, select Devices and Simulators:在 Xcode Window 菜单中,选择 Devices and Simulators: 在此处输入图片说明 then select the Simulators tab:然后选择模拟器选项卡: 在此处输入图片说明

Xcode -> Window -> Devices and Simulators -> Select Device which you want identifier (Inside details you can see identifier)

You can search for just the booted devices and get the iOS version (different from @TiBooX's answer which just shows the active devices).您可以仅搜索已启动的设备并获取 iOS 版本(与仅显示活动设备的@TiBooX 的答案不同)。 You also don't need to use grep , you can just use the built in functionality of xcrun :您也不需要使用grep ,您可以只使用xcrun的内置功能:

$ xcrun simctl list 'devices' 'booted'

Which will print out something like:这将打印出如下内容:

== Devices ==
-- iOS 10.3 --
-- iOS 11.4 --
-- iOS 12.4 --
-- iOS 13.4 --
    iPhone 11 Pro (A5DEEA78-1E82-472E-B7CC-FFD27741CDA2) (Booted)
-- tvOS 13.4 --
-- watchOS 6.2 --

I would recommend adding the following alias to your .bashrc or .zshrc :我建议将以下别名添加到您的.bashrc.zshrc

# Get the active simulator with
alias active-sims="xcrun simctl list 'devices' 'booted'"

This way you can just run active-sims without remembering the entire line every time.这样你就可以只运行active-sims而不必每次都记住整行。

You can visually review the value in the simulator by navigating to home/Settings/General/About/Serial Number which is the same as your desktop machine.您可以通过导航到与您的台式机相同的 home/Settings/General/About/Serial Number 来直观地查看模拟器中的值。 You can verify this by navigating to Apple/About This Mac and clicking the OS version number under OS X (the display will change to indicate your UDID - you may need to click it twice).您可以通过导航到 Apple/About This Mac 并单击 OS X 下的操作系统版本号来验证这一点(显示将更改以指示您的 UDID - 您可能需要单击它两次)。

还有另一种不使用命令行的方法,在这个 plist 文件 ~/Library/Developer/CoreSimulator/Devices/device_set.plist 中,它列出了所有带有 UUID 的设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM