Xcode 15.3中iOS Simulator周期性消失,求非重启解决方法?
iOS Simulator周期性消失的替代解决方法
我的iOS Simulator会周期性消失:
重启或注销再登录可解决该问题,但相关设备类型目录(如/Applications/Xcode-15.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPad Air (4th generation).simdevicetype/Contents/MacOS/iPad Air (4th generation))均正常存在,实际设备类型文件数量充足:
drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad (10th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad (5th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad (6th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad (7th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad (8th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad (9th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Air (3rd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Air (4th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Air (5th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Air 2.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (10.5-inch).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (11-inch) (1st generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (11-inch) (2nd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (11-inch) (3rd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (11-inch) (4th generation) (16GB).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (11-inch) (4th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (1st generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (2nd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (3rd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (4th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (5th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (6th generation) (16GB).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (12.9-inch) (6th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad Pro (9.7-inch).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad mini (5th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad mini (6th generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPad mini 4.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 11 Pro Max.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 11 Pro.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 11.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 12 Pro Max.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 12 Pro.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 12 mini.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 12.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 13 Pro Max.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 13 Pro.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 13 mini.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 13.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 14 Plus.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 14 Pro Max.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 14 Pro.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 14.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 15 Plus.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 15 Pro Max.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 15 Pro.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 15.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 6s Plus.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 6s.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:46 iPhone 7 Plus.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:46 iPhone 7.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 8 Plus.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone 8.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone SE (1st generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:46 iPhone SE (2nd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone SE (3rd generation).simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone X.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone Xs Max.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone Xs.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPhone Xʀ.simdevicetype drwxr-xr-x 3 agraph staff 96 Feb 4 02:47 iPod touch (7th generation).simdevicetype
另外,/Library/Developer/CoreSimulator/Images/ 目录内容如下:
drwxr-xr-x@ 7 root admin 224 Apr 12 18:50 . drwxr-xr-x 7 root admin 224 Aug 3 2023 .. -rw------- 1 root admin 7351124481 Jan 9 16:10 00470611-A65E-4C90-9320-B17E3DC07E08.dmg -rw------- 1 root admin 7229057541 Mar 6 15:38 400CE2B6-8AB0-44F8-939A-290B35DCBE8D.dmg drwxr-xr-x 2 root admin 64 Mar 6 15:38 Inbox -rw-r--r-- 1 root admin 2244 Apr 12 18:50 images.plist drwxr-xr-x 2 root admin 64 Mar 6 15:38 mnt
(/Library/Developer/CoreSimulator/Images/mnt/ 目录内为空)
替代解决方法
1. 重启CoreSimulator服务
打开终端,执行命令强制重启CoreSimulator核心服务:
killall -9 com.apple.CoreSimulator.CoreSimulatorService
执行后重新打开Xcode,模拟器设备列表通常会自动重新加载。
2. 重置模拟器设备(需注意备份数据)
- 图形界面操作:
打开Xcode,点击顶部菜单Window > Devices and Simulators,在Simulators标签页选中所有消失的设备,右键选择Delete,再点击左下角+按钮重新添加需要的设备类型。 - 终端命令重置:
执行以下命令清除所有模拟器数据(会删除模拟器内的应用、设置等,建议提前备份):
之后重新打开Xcode即可重新创建模拟器。xcrun simctl erase all xcrun simctl delete all
3. 清理Xcode缓存并重新加载配置
关闭Xcode和所有模拟器窗口,执行命令删除Xcode缓存文件:
rm -rf ~/Library/Caches/com.apple.dt.Xcode rm -rf ~/Library/Developer/Xcode/DerivedData
重新打开Xcode,等待索引完成后查看模拟器是否恢复正常。
4. 修复CoreSimulator目录权限
执行命令修复/Library/Developer/CoreSimulator/目录的权限问题:
sudo chown -R root:admin /Library/Developer/CoreSimulator sudo chmod -R 755 /Library/Developer/CoreSimulator
输入系统密码后执行,完成后重新打开Xcode验证。
内容的提问来源于stack exchange,提问作者Anton Tropashko
相关产品推荐
相关产品推荐

