ios iPhone解锁时Xcode“设备锁定”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26791477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 03:31:50  来源:igfitidea点击:

Xcode "Device Locked" When iPhone is unlocked

iosiphonexcodedevice

提问by Faisal Syed

When I tried to build and run, Xcode said my device was locked. I looked at my iPhone, and it's not locked at all. How do I fix this?

当我尝试构建和运行时,Xcode 说我的设备被锁定。我看了看我的 iPhone,它根本没有被锁定。我该如何解决?

采纳答案by tehprofessor

Did you by chance not "trust" the device? This will prevent it from communicating with xcode even if the device is unlocked.

您是否偶然不“信任”该设备?即使设备已解锁,这也将阻止它与 xcode 通信。

Update here's a support doc from Apple: http://support.apple.com/en-us/HT5868

更新 Apple 的支持文档:http: //support.apple.com/en-us/HT5868

回答by Abhi Beckert

My phone was set to "trust" the Mac, and I still ran into this error with Xcode 6.1.1.

我的手机被设置为“信任”Mac,但我仍然在使用 Xcode 6.1.1 时遇到了这个错误。

This worked for me:

这对我有用:

  • unplug device
  • quit xcode
  • open xcode
  • plug in device
  • build/run
  • 拔掉设备
  • 退出 xcode
  • 打开 xcode
  • 插入设备
  • 构建/运行

回答by Iron John Bonney

I recently ran into this issue with XCode 8 just after updating my device from iOS 9 to 10. The exact error I received was:Development cannot be enabled while your device is locked. Please unlock your device and reattach.I received this error even when my phone was unlocked, and after unplugging and re-plugging in the device.

我最近在将我的设备从 iOS 9 更新到 10 后就遇到了 XCode 8 的这个问题。我收到的确切错误是:Development cannot be enabled while your device is locked. Please unlock your device and reattach.即使我的手机被解锁,我也收到了这个错误,并且在拔下并重新插入设备后。

As is mentioned in several answers, the device is lockedmessage is actually referring to the device not trusting the MacBook. In my case, I think my phone defaulted to not trusting my computer after updating to iOS 10. Here are the steps that worked for me to reset the settings (this is the same process that is mentioned in the Apple support page in tehprofessors' answer):

正如几个答案中提到的,该device is locked消息实际上是指不信任 MacBook 的设备。就我而言,我认为我的手机在更新到 iOS 10 后默认为不信任我的计算机。以下是对我有用的重置设置的步骤(这与 tehprofessors 回答中 Apple 支持页面中提到的过程相同):

  1. Disconnect your device from your MacBook and close Xcode.
  2. On your device go to Settings > General > Reset, then tap Reset Location & Privacy
  3. Plug your device back into your computer, and on the device you will be prompted to trust the computer. Tap trust.
  4. Now reopen Xcode and rebuild the project.
  5. The device lockederror should disappear.
  1. 断开设备与 MacBook 的连接并关闭 Xcode。
  2. 在您的设备上,前往Settings > General > Reset,然后轻点Reset Location & Privacy
  3. 将您的设备重新插入计算机,然后在设备上会提示您信任计算机。点击信任。
  4. 现在重新打开 Xcode 并重建项目。
  5. device locked错误应该消失。

回答by Asfand Shabbir

From the Window Menu in top bar of Xcode, select Devices and Simulators.

从 Xcode 顶部栏中的窗口菜单中,选择设备和模拟器。

(or Press SHIFT + COMMAND + 2)

(或按 SHIFT + COMMAND + 2)

Then select your device, right click and select Unpair.
Once you do this Trust or Don't trust will appear on your device.
Trust the device again and it will begin preparing it for Development.
Wait for Xcode to pair device for development and then you are good to go!

然后选择您的设备,右键单击并选择取消配对。
执行此操作后,“信任”或“不信任”将出现在您的设备上。
再次信任该设备,它将开始为开发做准备。
等待 Xcode 配对设备进行开发,然后您就可以开始了!

回答by Itzdsp

I ran in to the same issue even though i selected "Trust this computer" option first time.

即使我第一次选择了“信任这台计算机”选项,我也遇到了同样的问题。

This worked for me

这对我有用

  1. Lock the device
  2. Remove cable from device.
  3. Unlock the device
  4. Connect again to Mac
  1. 锁定设备
  2. 从设备上拔下电缆。
  3. 解锁设备
  4. 再次连接到 Mac

回答by Nik Kov

2018

2018年

The fastest way for now i found is:

我现在找到的最快方法是:

1) Go to Window -> devices(changed the hotkey in xcode to CMD+P for me)
2) Press unpairon the device. enter image description here
3) Press trustin iPhone.
4) Build again or Run without building (Ctrl+CMD+R)

1)转到窗口 - >设备(为我将xcode中的热键更改为CMD + P)
2)按设备上的取消配对。 3) 按iPhone 的信任。 4) 重新构建或不构建运行 (Ctrl+CMD+R)在此处输入图片说明

回答by Amber K

For anyone who need a logical answer..

对于任何需要合乎逻辑的答案的人..

  1. Go to Window -> Devices & Simulators. Right click on your device & unpair it.
  2. Disconnect from cable & reconnect.
  3. Wait for it & let Xcode detect you device.
  4. Run the project.
  5. Make sure you TRUSTon your iOS device and enter any passcode.
  1. 转到窗口 -> 设备和模拟器。右键单击您的设备并取消配对。
  2. 断开电缆连接并重新连接。
  3. 等待并让 Xcode 检测您的设备。
  4. 运行项目。
  5. 确保您信任您的 iOS 设备并输入任何密码。

回答by kris

Rebooted my iPhone, and that fixed it for me.

重新启动我的 iPhone,并为我修复了它。

I tried every answer on this page (7 at the time, though 2 are duplicates) and they were all unsuccessful for getting rid of this Xcode error for me.

我尝试了此页面上的所有答案(当时有 7 个,但有 2 个是重复的),但都没有成功为我摆脱这个 Xcode 错误。

回答by Vlad Papko

For those who has this issue in Xcode 9: Simply restarting Xcode should solve the problem.

对于那些在 Xcode 9 中遇到此问题的人:只需重新启动 Xcode 即可解决问题。

回答by Starsky

I have a very simple solution which worked for me instantly. Takes some 10 sec to do:

我有一个非常简单的解决方案,它立即对我有用。需要大约 10 秒才能完成:

1) Go to Window -> Devices & Simulatorsand untick Show as run destination

1) 前往Window -> Devices & Simulators并取消勾选Show as run destination

enter image description here

在此处输入图片说明

2) Unplug the cable and plug it back in.

2) 拔下电缆并重新插入。

3) Run the project.

3) 运行项目。

This should be solving your problem!

这应该可以解决您的问题!