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
4
Answers
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.
Credit: https://developers.apple.com/forums/thread/681571?answerId=690251022#690251022
Quit XCode and run this terminal command:
Then open your project, build it and try reloading the preview.
Changing the Derived Data location in XCode to "Default" appears to fix a related issue:
XCode preferences
In my case, I discovered that I had an unfortunate directory name collision – specifically, I had both
and
Deleting both of them solved the problem (in my case, the app widget worked in the simulator, but in the Xcode canvas, it would not launch.