当你运行真机时遇到报错:Failed to prepare the device for development. This operation can fail if the version of the OS on the device is incompatible with the installed version of Xcode. You may also need to restart your Mac and device in order to correctly detect compatibility.
大概率是,你的xcode的支持的设备不包含你当前设备的系统版本,如果不确定现在的Xcode是否支持调试的设备的系统版本,可以在系统终端中运行以下代码:
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
显示的内容如图所示
如果没有,有两种办法可以解决以上问题
1、更新Xcode版本
备注:Xcode应用版本受限于Mac OS系统版本,Mac OS系统版本受限于 Mac 电脑生产时间,如果你电脑太旧不想更换电脑,或者使用黑科技安装系统的话,就选择第二种方式吧
2、下载支持真机版本的文件,将文件导入上面地址中 文件连接
将文件解压
将整个文件夹拖入到 DerviceSupport 文件夹中
大功告成,去 Xcode 进行真机调试吧!