Xcode "Device Locked" When iPhone is unlocked
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?
Solution 1:
My phone was set to "trust" the Mac, and I still ran into this error with Xcode 6.1.1.
This worked for me:
- unplug device
- quit xcode
- open xcode
- plug in device
- build/run
Solution 2:
Did you by chance not "trust" the device? This will prevent it from communicating with xcode even if the device is unlocked.
Update here's a support doc from Apple: http://support.apple.com/en-us/HT5868
Solution 3:
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.
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):
- 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.
Solution 4:
From the Window Menu in top bar of Xcode, select Devices and Simulators.
(or Press 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!
Solution 5:
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