Reputation: 799
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:
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
Upvotes: 7
Views: 9585
Reputation: 21
/Users/me.myself/Library/Developer/Xcode/UserData/Previews run
4.Restart Xcode
Upvotes: 0
Reputation: 1
Changing Derived data and Archives to "Default" worked for me.
I was using an external SSD to store the file and I had a custom path. After changing it in Settings/Locations it worked
Upvotes: 0
Reputation: 1169
In my case, I discovered that I had an unfortunate directory name collision - specifically, I had both
~/Library/Developer/Xcode/UserData/Previews/Simulator\ Devices
and
~/Library/Developer/Xcode/UserData/Previews/Simulator%20Devices
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.
Upvotes: 5
Reputation: 71
Changing the Derived Data location in XCode to "Default" appears to fix a related issue:
MessageSendFailure: Message send failure for update
==================================
| RemoteHumanReadableError
|
| LoadingError: failed to load library at path...
Upvotes: 0
Reputation: 799
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
Upvotes: 13
Reputation: 365
Quit XCode and run this terminal command:
xcrun simctl --set previews delete all
Then open your project, build it and try reloading the preview.
Upvotes: 10