Xcode Device Locked When iPhone is unlocked
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When Xcode says an iPhone is locked even though the screen is clearly awake and unlocked, the problem is usually not the display state. Xcode needs a valid trust relationship, a working developer connection, and in recent iOS versions the correct development permissions as well.
That is why repeatedly unlocking the screen rarely fixes the issue by itself. The more reliable fix is to repair the pairing path between the Mac, Xcode, and the device.
What Xcode Means by “Locked”
For deployment and debugging, Xcode requires more than a visible home screen. It also needs:
- the device to trust the Mac
- a usable USB or wireless pairing session
- access to developer services on the phone
- a stable connection long enough to install and launch the app
If any of those are stale, Xcode can report the device as effectively locked even while the phone looks ready to use.
Start with the Trust Relationship
The first pass should be simple and mechanical:
- unlock the iPhone with the passcode
- keep it on the home screen
- reconnect the cable
- watch for the
Trust This Computerprompt - accept the prompt and enter the passcode again if requested
If you are using wireless debugging, reconnect over USB first. That removes one variable while you rebuild the pairing state.
You can check whether Xcode sees the device at all with the command-line tools that ship with Xcode:
If the phone appears inconsistently or flips between available and unavailable, the pairing path is still unstable.
Reset Pairing State When It Looks Stale
A device that worked yesterday and fails today often has stale trust records rather than a new project bug. The fastest reset is usually:
- unplug the device
- quit Xcode
- on the iPhone, reset
Location & Privacy - reconnect the cable
- trust the Mac again
- reopen Xcode
Resetting Location & Privacy forces the phone to ask again whether the computer should be trusted. That often clears the false “locked” state.
Check Development Permissions
On newer iOS versions, development access may still fail even after pairing succeeds. If the device is visible for file or media access but Xcode cannot deploy, confirm that Developer Mode is enabled on the phone in Settings > Privacy & Security > Developer Mode.
If Developer Mode was toggled recently, restart the device before retrying. The setting is not always effective until the reboot completes.
Isolate Cable, Port, and Host Issues
Do not over-focus on Xcode if the physical connection is flaky. A bad cable or USB hub can produce the same symptoms as a trust problem. Use a direct cable connection to the Mac, avoid hubs for the first test, and if possible try another cable and USB port.
If the device is still unreliable, reboot both the Mac and the iPhone. That sounds basic, but device services on both sides can get stuck in a way that survives simple reconnects.
Common Pitfalls
- Assuming an unlocked screen guarantees a valid development session.
- Ignoring or dismissing the
Trust This Computerprompt. - Continuing over wireless debugging while pairing is already unstable.
- Forgetting to enable
Developer Modeon newer iOS versions. - Blaming the project setup when the real problem is a stale trust record or bad cable.
Summary
- Xcode’s “device locked” message usually points to trust or developer-session state, not just screen lock state.
- Rebuild the pairing path first by reconnecting, trusting the Mac again, and retrying over USB.
- Use
xcrun xcdevice listorxcrun devicectl list devicesto confirm what Xcode sees. - Reset
Location & Privacyif the trust relationship looks stale. - Check
Developer Mode, cable quality, and USB path before assuming the app project is at fault.

