The Xcode error occurs when the xcode version and ios versions don’t match. Usually it happens when the Xcode version is less than the device iOS version. i.e. the Xcode is too old for the device. This is a compatibility issue which can be resolved by performing some steps.
Always check if the device you are using has compatible iOS version to the Xcode version, if not Xcode requires an update.
If you are not able to update XCode or there is no update being shown for Xcode, please check if the OS needs an update.
In some cases you would not like to update your xcode but still need to fix the issue, then you’ll have to download the latest version of Xcode, but do not install it, just download.
Right click on the installer, select show package contents
Select contents > Developer > Platforms > iPhoneOS.platform > Device support
Copy the folder with iOS Version of your device
Right click on the installed Xcode.
Perfrom step b again but this time instead of copying the folder, paste it there.
Restart your xcode and the error will vanish.