如何修复 iOS Simulator [native-run] ERR_DEVICE_LOCKED:设备在 Apple Silicon (M1) 上 1 分钟后仍被锁定?

问题描述

无论 --target 变量如何,以下命令都会失败:

ionic cordova run ios --target="iPhone-X"

ionic cordova run ios --target="iPhone 12"

ionic cordova emulate ios --debug --target="iPhone 11" -- --buildFlag="-UseModernBuildSystem=0"

错误是:

[native-run] ERR_DEVICE_LOCKED: Device still locked after 1 minute. Aborting.
[ERROR] An error occurred while running subprocess native-run.

这是在我改用 Apple Silicon (M1) MacBook Pro 后发生的,但我不确定 100%。谢谢!

解决方法

我今天遇到了同样的问题,结果证明它使用“目标 ID”而不是“目标名称”。

  1. 使用 --list 选项检查可用目标列表
ionic cordova run ios --list
  1. 使用 TARGET ID 运行相同的命令。
ionic cordova run ios --target="...TARGET-ID-1A2B3B..."

顺便提一下,我使用的是基于 INTEL 的 MacBook Pro。

,

对我来说,这条消息发生在不同的情况下。该设备尚未注册到 Apple 帐户!

所以我用 XCode 启动了一次,它自动注册了设备(对我来说)然后它就可以工作了。

,

在这里,我执行了:

native-run ios --virtual --list

接下来,

cordova build ios --debug --emulator && native-run ios --app platforms/ios/build/emulator/MyApp.app --virtual --forward 8100:8100 --target <TARGET ID>

其他选择:

native-run ios --app platforms/ios/build/emulator/MyApp.app --virtual --forward 8100:8100 --target <TARGET_ID>
,

这对我有用!

使用 --list 选项检查可用目标列表

ionic cordova run ios --list

使用 TARGET ID 运行相同的运行命令。

ionic cordova run ios --target="XXXXXXXXXXXXXXX"