Most developers run into the Xcode Failed to Prepare Device for Development error at some point in their career. It can be frustrating because the error isn't very helpful. In this tutorial, I share four possible causes and provide some tips to resolve the problem.
Enable Developer Mode
Apple continues to tighten privacy and security. That is a good thing, but it can at times result in unexpected errors. Apple introduced Developer Mode in iOS 16 and watchOS 9. When disabled, it prevents a developer from installing an app through Xcode.
Open the Settings app on your device and navigate to Privacy & Security. Scroll to the Security section and enable Developer Model if it is set to Off.
Xcode Is Out of Date
Xcode can only support the operating systems it ships with. If your device runs an operating system that Xcode doesn't support, then it isn't able to prepare your device for development.
This issue pops up every year and I explain it in more detail in Could Not Locate Device Support Files. Let's say Apple releases a beta version of their operating system and you install it on your device. In that scenario, you are no longer able to use that device with your current Xcode installation because it is unaware of the beta version you installed on your device.
Make sure you have the latest version of Xcode installed on your development machine. I always download Xcode from Apple's developer website, not Apple's Mac App Store. If you installed a beta version on your device, then you need install the Xcode version that supports that beta version. I explain this in more detail in Could Not Locate Device Support Files.
Operating System Version Is Out of Date
While less likely, it is possible the version of the operating system (iOS, tvOS, macOS, watchOS) isn't supported by the version of Xcode you have installed because the operating system is too old.
The only solution is to update the operating system of your device if that is possible. It can be useful to keep old(er) devices around for testing, but those devices may become incompatible with the version of Xcode your are using.
The Device Isn't Trusted
When you connect a device to your development machine for the first time, you are asked whether it is safe to trust your development machine. If you choose Don't Trust, then Xcode isn't able to prepare your device for development.
Disconnect your device from your development machine. Reconnect your device and make sure you choose Trust if you are asked whether it is safe to trust your development machine.
If you aren't sure whether you trusted your development machine, you can clear trusted computers in the Settings app. Open the Settings app and navigate to the Developer settings. Tap the Clear Trusted Computers button to start with a clean slate.
Device Not Set Up in Developer Account
Make sure that the device is registered with Apple and linked to your developer account. You can do this through Xcode or through the Apple developer portal.
Are you still having issues?
The most likely reason you are seeing this error is an out of date version of Xcode. As a developer, I don't let the operating system install updates automatically because that can lead to issues like this. Automatic updates is fine for third-party apps, but I want to control which version of the operating system runs on my devices. That simple change can save you a lot of frustration and debugging.