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?
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.
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:
I ran in to the same issue even though i selected "Trust this computer" option first time.
This worked for me
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
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.
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!