Xcode “Device Locked” When iPhone is unlocked

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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....possible bug? How do I fix this?





lock it and unlock it again
– ChrisH
Nov 6 '14 at 23:50





tried it, still no luck
– Faisal Syed
Nov 6 '14 at 23:59





For me, unplugging and re-plugging did the trick. No need to Clean Build Folder, restart Mac with Command+Option+P+R, leave the house and come back again, burn a Voodoo doll of Steve Jobs, etc.
– Nicolas Miari
Sep 16 '16 at 3:22





I solved this issue with disabling hotspot
– levye
Jan 28 '17 at 10:20





@NicolasMiari For me it has not worked and I am looking for the Voodoo doll
– zirinisp
Dec 20 '17 at 12:23




28 Answers
28



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'm not sure what you mean by "trust"...how do i enable that?
– Faisal Syed
Nov 6 '14 at 23:59





Unplug the device, close xcode, and then open xcode and plugin the device. When you plug it in (after unlocking it) it you should be prompted to "trust" the computer (in the iOS device). My guess is you may have accidentally tapped "do not trust" and so the device will refuse to connect to the computer.
– tehprofessor
Nov 7 '14 at 0:01





I've updated the answer with a link to apple support page regarding the issue.
– tehprofessor
Nov 7 '14 at 0:02





This is really weird because in my case, I was never prompted to trust in the first place...
– Nicolas Miari
Jun 6 at 2:57





@NicolasMiari I've had other notifications show up at the same time I plug in my phone causing it disappear, or accidentally dismissing the prompt on my Mac... as well, if you've used mobile configurator there is a chance it's causing some weird issues as the device could be configured to only respond to one machine. Perhaps that handshake got messed up the first time you plugged it in?
– tehprofessor
Jun 7 at 21:13



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



This worked for me:





Unfortunately this is too often the solution for many of your weird Xcode woes.
– Jarsen
Dec 20 '15 at 3:58





And every time quiting the Xcode is wasteful.
– Nik Kov
7 mins ago



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.


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


Settings > General > Reset


Reset Location & Privacy


device locked





yep unfortunately only this worked for me on from Xcode 8 on iOS 10 :(
– Bishal Ghimire
Oct 25 '16 at 3:41





@BishalGhimire Yeah, it's definitely not ideal. I actually just had to do this reset again as XCode started giving me the device is locked message again without any noticeable changes to any of my iPhone's settings or XCode's settings. Somewhere along the way my trust settings for my computer are being reset, but I'm not sure when and where.
– Iron John Bonney
Oct 25 '16 at 19:16




device is locked





you should wait for a while to processing symbol files
– Hamed Gh
Nov 20 '16 at 7:22







Hmm... this fixed the "Device Locked" error ... but has replaced it with a "Could not save the pairing record." error ...
– kris
Dec 20 '16 at 4:22





this worked for me after iOS 11 software update on device / Xcode 9
– Ben
Oct 18 '17 at 10:22



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!





The problem usually is not waiting for xcode to prepare iPhone to debug :) this worked
– Abdelrahman Ellithy
Apr 24 at 4:02



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



This worked for me





Abhi Beckert's answer above worked for me before, this worked for me now. I spend a ridiculously large amount of my time tap-dancing around Apple's inept developers.
– amergin
Jun 16 '17 at 9:44





thats aApple for you! changing some value in IB's attribute inspector will make your xcode faster. lol.
– Itzdsp
Jun 16 '17 at 15:59





This solved my issue!
– Hao Zheng
Oct 28 '17 at 2:26



For anyone who need a logical answer..





This worked. Make sure your device is UNLOCKED when you initially pair it. If not then follow these instructions to repair.
– Wizkid
May 14 at 15:29



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.





This saved my day! Thank you!
– Fangming
Oct 19 '17 at 1:05





This is the best answer which save my lot of time. Thanks
– Gaurav
Nov 14 '17 at 11:26





Didn't helped for me. Only setting untrusted and trust again helped.
– Nik Kov
Feb 17 at 10:48







You don't need to reboot or restart every time..check my answer: stackoverflow.com/a/50023756/9623144
– Amber K
Jun 20 at 3:43





It's a waste of time to reboot the phone every time.
– Nik Kov
11 mins ago



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





This is correct and especially true in the case of wifi debugging in Xcode 9.
– Ben Lachman
Nov 12 '17 at 0:02



A simple solution:



First, unplug your device.



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



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





The same for me. With addition that I was able to debug wireless.
– Mykhailo Lysenko
Dec 23 '17 at 12:29



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



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


Disconnect device


connect again



Solution 2 :



i. Restart you device


Restart you device



Solution 3 :



i. Disconnect device


Disconnect device



ii. Quit Xcode (Shortcut key : cmd + Q)


Quit Xcode


cmd + Q)



iii. Open your project


Open your project



iv. Clean project (Shortcut key : cmd + shift + K)


Clean project


cmd + shift + K



v. Now connect device


connect device



vi. Run your project


Run



For me Solution 3 worked perfectly





Solution #3 is what worked for me.
– capikaw
Apr 23 at 20:37



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



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.





Still not working(
– Nik Kov
10 mins ago



I follow the below steps its worked for me in iOS 10.



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.



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.



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.





I had the same problem (update was waiting on device) but I didn't have time to update it. Asfand Shabbir's answer worked. (in case readers don't have time to update)
– Can Poyrazoğlu
May 6 at 10:55



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.



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.



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.



All the previous solutions didn't work.



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



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





this is what I had to do as well to get the 'trust this computer?' prompt to appear when I connected to my computer
– Nunchucks
Jun 26 at 20:31



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.



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



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.



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.



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)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

s6TEDqYFaes2,3,Xd v6k63Z1AwECg kUWiR8,jppWxer7 AtfNwH,4 5BPiZ
h9dGKJDT,53ulCHpUxmtTswR,lY9CWE53aenqmc4dhU hrgKcXo9 bO6f7 4qJxfPs0yC6rN QZh9By92khajIdqaNaIDx4Hz Pf

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results