Xcode 10上的iOS模拟器崩溃

Xcode 10上的iOS模拟器崩溃

问题描述:

今天,我已经将我的iMac从macOS High Sierra更新为macOS Mojave.从那时起,我无法打开模拟器.每次我尝试打开立即崩溃的模拟器时.每当我尝试通过Xcode运行模拟器时,Xcode都会显示此错误

Today, I've updated my iMac to macOS Mojave from macOS High Sierra. Since then I'm not able to open simulator. Every time I tried to open the simulator that crashes immediately. Whenever I tried to run the simulator via Xcode then Xcode shows this error

超时,等待iphonesimulator的模拟器应用程序准备就绪

Timed out waiting for the simulator application for iphonesimulator to become ready

此外,我尝试直接打开模拟器,它立即崩溃.此处的gif(gif有点慢)-

Also, I tried to open the simulator directly and it's crash immediately. Here the gif (gif is a little bit slow) -

系统CPU和内存状态-

这里有一些我尝试过但没有运气的解决方案-

  1. 清除iPhone模拟器缓存

  1. Clear iPhone Simulator Cache

xcrun simctl erase all

  • 清除派生数据

  • Clear DerivedData

    ~/Library/Developer/Xcode/DerivedData/
    

  • 清除iOS设备支持

  • Clear iOS DeviceSupport

    ~/Library/Developer/Xcode/iOS DeviceSupport/
    

  • 删除Xcode首选项

  • Delete Xcode Preferences

    defaults delete com.apple.dt.Xcode
    

  • 重新启动Xcode&系统

  • Restart Xcode & System


    更新1

    macOS日志-

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Device iPhone XS (978302BA-5255-44CB-A77C-188071B99A7C, iOS 12.0, Booted) is available but has no defaultDisplay'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x00007fff33a9543d __exceptionPreprocess + 256
        1   libobjc.A.dylib                     0x00007fff5f9a6720 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff33ab008e +[NSException raise:format:arguments:] + 98
        3   Foundation                          0x00007fff35e4c55d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
        4   Simulator                           0x000000010e7510da Simulator + 106714
        5   libdispatch.dylib                   0x00007fff60a24d4f _dispatch_call_block_and_release + 12
        6   libdispatch.dylib                   0x00007fff60a25dcb _dispatch_client_callout + 8
        7   libdispatch.dylib                   0x00007fff60a2c120 _dispatch_lane_serial_drain + <…>
    )
    

  • 此命令应该可以解决您的问题(先关闭sim,然后再打开):

    This command should fix your issue (close sim before and open after):

    sudo killall -10 com.apple.CoreSimulator.CoreSimulatorService
    

    此后,重新启动Xcode,如果模拟器不可用,那么我们需要从Windows> Device and Simulators

    After this, restart Xcode and if simulator not available then we need to add them manually from Windows > Device and Simulators