Xcode "Device Locked" When iPhone is unlocked

IosIphoneXcodeDevice

Ios Problem Overview


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?

Ios Solutions


Solution 1 - Ios

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 - Ios

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 - Ios

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):

  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 locked error should disappear.

Solution 4 - Ios

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 - Ios

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

Solution 6 - Ios

###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 unpair on the device. enter image description here
  3. Press trust in iPhone.
  4. Build again or Run without building (Ctrl+CMD+R)

Solution 7 - Ios

Rebooted my iPhone, and that fixed it for me.

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.

Solution 8 - Ios

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 TRUST on your iOS device and enter any passcode.

Solution 9 - Ios

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

  1. Go to Window -> Devices & Simulators and untick Show as run destination

enter image description here

  1. Unplug the cable and plug it back in.

  2. Run the project.

This should be solving your problem!

Solution 10 - Ios

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

Solution 11 - Ios

This happens at times while using Xcode 9.

Screenshot

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

Solution 12 - Ios

A simple solution:

  1. First, unplug your device.

  2. Now, unlock your device and plug it in again. Be sure that the device is unlocked.

  3. Now run the Xcode project by selecting the device as target.

Solution 13 - Ios

When you plug in your iPhone, it will ask you to trust the computer. If you already trust and unlocked but still said your device was locked (bug). Just unplug and plug again then it will work

Solution 14 - Ios

These steps worked for me in iOS 10.

  1. Remove the cable from device.
  2. Plug in the device.
  3. Clean and build the Xcode project.

Solution 15 - Ios

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.

Solution 16 - Ios

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.

Solution 17 - Ios

There is a simple way to resolve that. At least it works for me. In your iPhone Device Go to Setting > Developer > click in “Clear Trusted Computer” Type the passcode required And done!!!

The simplest way that I found.

Solution 18 - Ios

This issue is not about "Trust" or not. It's a bug in Xcode.

Just follow these steps.

When Xcode is running and your device is connected:

  1. Lock your device.
  2. Unplug your device from Mac.
  3. Unlock your device.
  4. Plug your device back to Mac.

Solution 19 - Ios

Solution: Switch target device to some other (e.g. Generic iOS Device),

enter image description here

then unlock you physical device and switch back to it again.

Solution 20 - Ios

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.

Solution 21 - Ios

there are two solution worked for me.

  1. disconnect your device from the mac and reattach it.
  2. disconnect your device from the mac and restart it and then connect it with mac it'll work

Solution 22 - Ios

sometimes your device stops trusting your PC for no reseaon. go to your settings then general > reset > reset location and privacy. and replug your device to your PC again and press "trust this device" prompt that shows up in your phone.

Solution 23 - Ios

Lots of answers, but the one that worked for me (El Capitan, Xcode 8.2) was to close iTunes. If that has a connection to the IOS device then although Xcode can load the app components it will still fail to run it.

Solution 24 - Ios

On your device (iPhone/iPad) goto: Settings -> Developer -> Clear Trusted Computers worked for me.

Solution 25 - Ios

I found that by shutting down a Console and a running Simulator allowed XCode to see my iPhone again. I'd make sure other related programs aren't running if you don't need them.

Solution 26 - Ios

This can also happen due to pending update on your device. This also means you need to update your phone, connect to the MacBook (trust it if needed). This how I found my problem and solution.

Solution 27 - Ios

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.

Solution 28 - Ios

Another fix to this problem is to connect your iPhone with your Xcode open while your iPhone is in the homescreen, not in lockscreen or with an app opened.

Solution 29 - Ios

All the previous solutions didn't work.

Finlay, changing the iPhone's cable solved the problem.

Solution 30 - Ios

I had to re-add device to xcode.

In XCode open Devices and Simulators (CMD+Shift+2), in left list press + button and re-add the same device.

Solution 31 - Ios

Check the "Low Power Mode" in disabled. In my case I just disable this check and the deploy works immediately,

Solution 32 - Ios

Bizare, but I hope it helps someone. I was connected to a VPN (Pro XPN) and that was causing the issue! Disconnected and it worked.

Solution 33 - Ios

For me, when I was about to unpair my device from xcode, I noticed it was just Preparing debugger support for my iPhone and it told me that "Xcode will continue when iPhone is finished." Similar to this issue

Solution 34 - Ios

Check that on the "Runner" option is selected the correct device. Although you have one device physically plugged in with a cable, Xcode could have connected via WiFi to any other device that has the "Connect via network" option enabled.

Check the

Solution 35 - Ios

My problem was I was trying to install on an unsupported (new) iOS version which produced the same errors. Specifically Xcode 11.7 to iOS 14

Solution 36 - Ios

For me my iPhone 12 has a connected Apple Watch, I had to trust my computer on my Apple Watch as well.

Solution 37 - Ios

I haven't seen this in any of the answers here, but the only thing that worked for me is an option on the device itself called Enable UI Automation. Supposedly it will turn itself off after an update. Go to Settings, Developer, then find Enable UI Automation.

This worked on my iPad 6th generation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFaisal SyedView Question on Stackoverflow
Solution 1 - IosAbhi BeckertView Answer on Stackoverflow
Solution 2 - IostehprofessorView Answer on Stackoverflow
Solution 3 - IosIron John BonneyView Answer on Stackoverflow
Solution 4 - IosAsfand ShabbirView Answer on Stackoverflow
Solution 5 - IosItzdspView Answer on Stackoverflow
Solution 6 - IosNike KovView Answer on Stackoverflow
Solution 7 - IoskrisView Answer on Stackoverflow
Solution 8 - IosAmber KView Answer on Stackoverflow
Solution 9 - IosStarskyView Answer on Stackoverflow
Solution 10 - IosVlad PapkoView Answer on Stackoverflow
Solution 11 - IosJayprakash DubeyView Answer on Stackoverflow
Solution 12 - Iosjaiswal RajanView Answer on Stackoverflow
Solution 13 - IosKeeleyView Answer on Stackoverflow
Solution 14 - IosJhansi MView Answer on Stackoverflow
Solution 15 - IosRoger ObaView Answer on Stackoverflow
Solution 16 - IosDeepin.DoView Answer on Stackoverflow
Solution 17 - IosCleiton DominguesView Answer on Stackoverflow
Solution 18 - IosTomView Answer on Stackoverflow
Solution 19 - IosPetr LazarevView Answer on Stackoverflow
Solution 20 - IosLZMView Answer on Stackoverflow
Solution 21 - IosAhsanView Answer on Stackoverflow
Solution 22 - Iosuser3745290View Answer on Stackoverflow
Solution 23 - IosbrianlmerrittView Answer on Stackoverflow
Solution 24 - IosMateusz KaflowskiView Answer on Stackoverflow
Solution 25 - IosPaul K.View Answer on Stackoverflow
Solution 26 - IosAtarangView Answer on Stackoverflow
Solution 27 - IosMatt WagnerView Answer on Stackoverflow
Solution 28 - IosyannisalexiouView Answer on Stackoverflow
Solution 29 - IosAL3MSView Answer on Stackoverflow
Solution 30 - IosMartin JanečekView Answer on Stackoverflow
Solution 31 - IosCarlos Gabriel Gonzalez PView Answer on Stackoverflow
Solution 32 - IosKarl GjertsenView Answer on Stackoverflow
Solution 33 - IossalouriView Answer on Stackoverflow
Solution 34 - IosMengrolekView Answer on Stackoverflow
Solution 35 - Iosuser139816View Answer on Stackoverflow
Solution 36 - Ioswz366View Answer on Stackoverflow
Solution 37 - IosJusta GuyView Answer on Stackoverflow