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?
30 Answers
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
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.
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!
This happens at times while using Xcode 9.
There are multiple solution to this as mentioned below :
Note : Make sure that your device is not locked when Xcode is trying to install app.
Solution 1 :
i. Disconnect device
and connect again
Solution 2 :
i. Restart you device
Solution 3 :
i. Disconnect device
ii. Quit Xcode
(Shortcut key : cmd + Q)
iii. Open your project
iv. Clean project
(Shortcut key : cmd + shift + K
)
v. Now connect device
vi. Run
your project
For me Solution 3 worked perfectly
I run into this problem quite often (at least like 5 times a week). Almost every time this happens, a Xcode restart fixes it. But this time nothing seemed to work including:
- Restarting Xcode;
- Unplugging and re-plugging the iPhone;
- Cleaning the project (cmd+shift+k);
- Cleaning derived data (cmd+option+shift+k)
Done dozens of times in all sorts of different orders.
What fixed the issue for me this time was simply:
✅ Rebooting the Mac.
Recently I have met the Xcode shows "development cannot be enabled while your device is locked, Please unlock your device and reattach. (0xE80000E2).
If your iOS device is already unlocked and connected to mac and still get the error from Xcode 8.1 after upgrading to iOS 10.1.1, then the mac is not trusted by the device.
To fix it, first disconnect device to mac and then go to iOS settings app, and open general->reset->Reset Location & Privacy.
Then connect device to mac and when prompted, set select trust the mac.
Then wait the processing symbol files within your device and mac. After it finished, you can run the project to your device. It will be working.
Generally just unplugging/replugging seems to work for me. But today it didn't and something else seems to have worked: I have enabled network debugging on the device in question and it almost looked like it remembered an old network "lock" setting, while not seeing that the device was actually connected via USB. After (temporarily) de-selecting "Connect via Network" and replugging, it got things working again.
One possibility worth checking, if none of these other solutions work, is that there is no space left on the device. Xcode will not give you a helpful "device full" error to tell you that your device has no storage space left, but it will also not be able to deploy an app build to a device whose storage is full. The only solution in that situation is to delete media or other apps/data to free up enough space.