Disconect your iPhone (device) from your Mac.
Your Mac is not a "Trusted" computer. On your iPhone (device) go to Setting > Reset > Reset Location & Privacy.
Then connect your device to your Mac and answer "Trust" to the prompt.
This should correct your problem. It did for mey
After updated next version of Xcode and iOS, it is resolved.
I don't know what is the reason.
"After updated next version of Xcode and iOS, it is resolved."
It's now 2018, I'm running Xcode 9.2, with an iPhone running iOS 11.2, and this issue is still live and kicking.
My iPhone is unlocked, but XCode reports that "Development cannot be enabled while your device is locked."
Looking at the App Store, there are no Xcode updates available, so I'm stuck.
I'll say this for Apple, at least Xcode is consistantly dreadful.
When I try to test on the connected iPhone I have:
"Develpment cannot be enabled while your device is locked.
Please unlock your device and reattach.
I updated iOs to the beta vesion 11.3 (15E5216a) and Xcode to version 9.3 beta 4 (9Q127n), which is the one declared to support iOS beta 11.3. So it should not be in the need of updating Xcode.
My iPhone, connected to the iMac, is backed-up to iTunes, so it seems to me that it is trusted.
How can be this case approcched?
The Xcode project was still configured for iOS 11.2.
Changed the configuration to reflect the real iOS version 11.3 resolved the problem.
I had the same problems but it was solved by unpair and pair the phone again.
In XCode click Product>>Destination>>Add Aditional Simulators...
On Devices Tab Right Click on your device and select Unpair Device
Then unplug and plug in your phone again. There will be a prompt to trust this computer on the phone.
Select Trust and the XCode and the phone will start paring again.
(If there's another version of the same app on your phone you may have to delete it first.)
thank you. after my device updated, i got the same code error.
however, thanks to your solution, i can solve this error.
Xcode 10.2.1 (10E1001)
iPhone running iOS 12.3.1
New app using Swift 5.0.1