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
Xcode "Device Locked" When iPhone is unlocked
提问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 locked
message 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 支持页面中提到的过程相同):
- Disconnect your device from your MacBook and close Xcode.
- On your device go to
Settings > General > Reset
, then tapReset Location & Privacy
- Plug your device back into your computer, and on the device you will be prompted to trust the computer. Tap trust.
- Now reopen Xcode and rebuild the project.
- The
device locked
error should disappear.
- 断开设备与 MacBook 的连接并关闭 Xcode。
- 在您的设备上,前往
Settings > General > Reset
,然后轻点Reset Location & Privacy
- 将您的设备重新插入计算机,然后在设备上会提示您信任计算机。点击信任。
- 现在重新打开 Xcode 并重建项目。
- 该
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
这对我有用
- Lock the device
- Remove cable from device.
- Unlock the device
- Connect again to Mac
- 锁定设备
- 从设备上拔下电缆。
- 解锁设备
- 再次连接到 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.
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..
对于任何需要合乎逻辑的答案的人..
- Go to Window -> Devices & Simulators. Right click on your device & unpair it.
- Disconnect from cable & reconnect.
- Wait for it & let Xcode detect you device.
- Run the project.
- Make sure you TRUSTon your iOS device and enter any passcode.
- 转到窗口 -> 设备和模拟器。右键单击您的设备并取消配对。
- 断开电缆连接并重新连接。
- 等待并让 Xcode 检测您的设备。
- 运行项目。
- 确保您信任您的 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 & Simulators
and untick Show as run destination
1) 前往Window -> Devices & Simulators
并取消勾选Show as run destination
2) Unplug the cable and plug it back in.
2) 拔下电缆并重新插入。
3) Run the project.
3) 运行项目。
This should be solving your problem!
这应该可以解决您的问题!