Reputation: 4451
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?
Upvotes: 438
Views: 272739
Reputation: 1311
In my case I tried all above steps but only worked when I unpair the device:
Upvotes: 3
Reputation: 27050
This was happening on the Ventura (OSX 13.6) with Xcode 15.2
Go to Window -> Devices & Simulators
on your Xcode: For some the iPhone was under both the connected and disconnected devices list at the same time.
Remove (unpair) iPhone: I removed iPhone from the connected and disconnected devices.
Disconnect from the Cable
On iPhone Go to Settings -> Developer -> Clear Trusted Computers
Connect with the Cable
Press "Trust" on alert
Select iPhone
as a target to build and run the app
Upvotes: 1
Reputation: 1163
What fixed the issue for me: the USB<->lightning cable had to be connected directly through the mac, not through my LG 5k display (which is also a USB hub).
Upvotes: 1
Reputation: 2398
What solved the issue for me was unplugging the phone, then going to Devices and Simulators:
Then right click on the device and select Unpair.
Then plug your phone back in, Select "Trust this computer" and you should be golden.
Upvotes: 4
Reputation: 91
I spent hours trying to fix this issue with no luck.
BE SURE TO DISABLE ANY VPN SERVICES FROM YOUR IPHONE. Just like magic, it started working properly.
Upvotes: 8
Reputation: 131
There is no simple solution. The only real solution is to reboot the Mac, restart XCode and the iPhone. This is a shame, because it can happen at any time even in the middle of a session where everything was perfectly working, device paired and unlocked as needed. All other solutions given here or elsewhere can work here and now but fail tomorrow morning.
Upvotes: 0
Reputation: 2930
For me my iPhone 12 has a connected Apple Watch, I had to trust my computer on my Apple Watch as well.
Upvotes: 0
Reputation: 214
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
Upvotes: 0
Reputation: 2028
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
2) Unplug the cable and plug it back in.
3) Run the project.
This should be solving your problem!
Upvotes: 25
Reputation: 117
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.
Upvotes: -1
Reputation: 501
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
Upvotes: 4
Reputation: 2551
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):
Settings > General > Reset
, then tap Reset Location & Privacy
device locked
error should disappear.Upvotes: 125
Reputation: 1
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.
Upvotes: -2
Reputation: 821
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
Upvotes: 0
Reputation: 1410
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:
Done dozens of times in all sorts of different orders.
What fixed the issue for me this time was simply:
✅ Rebooting the Mac.
Upvotes: 8
Reputation: 111
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.
Upvotes: 11
Reputation: 81
These steps worked for me in iOS 10.
Upvotes: 8
Reputation: 325
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:
Upvotes: 6
Reputation: 13698
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.
3) Press trust in iPhone.
4) Build again or Run without building (Ctrl+CMD+R)
Upvotes: 46
Reputation: 189
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.
Upvotes: 3
Reputation: 4918
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.
Upvotes: 1
Reputation: 100
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.
Upvotes: 1
Reputation: 698
For anyone who need a logical answer..
Upvotes: 21
Reputation: 422
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.
Upvotes: 1
Reputation: 1294
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!
Upvotes: 90
Reputation: 36447
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
Upvotes: 12
Reputation: 95
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.
Upvotes: 1
Reputation: 1
Check the "Low Power Mode" in disabled. In my case I just disable this check and the deploy works immediately,
Upvotes: 0
Reputation: 4661
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.
Upvotes: 10
Reputation: 585
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.
Upvotes: 0