whilst working on an existing XCode project, the simulator began consistently crashing. The preview window will not show the current file, with a red banner and the below error:
MessageSendFailure: Message send failure for update
==================================
| MessageError: Connection interrupted
I have tried:
- Restarting XCode
- Restarting the Mac
- Cleaning the project
- Deleting DerivedData
- Deleting the local copy and cloning from GitHub
Nothing seems to be working. Does anyone know how to resolve this? It was working fine previously, seems to have broken at random.
I am using XCode 13.2.1
Edit: This is only affecting this app. Other projects still work fine
CodePudding user response:
Quit XCode and run this terminal command:
xcrun simctl --set previews delete all
Then open your project, build it and try reloading the preview.
CodePudding user response:
I managed to fix this by wrapping the ContentView() call in the preview in a ZStack. This is a known bug caused by @FocusState when used in a top-level view that the preview window is rendering.
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ZStack {
ContentView()
}
}
}
Credit: https://developers.apple.com/forums/thread/681571?answerId=690251022#690251022