skip to Main Content

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


  1. Chosen as BEST ANSWER

    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


  2. Quit XCode and run this terminal command:

    xcrun simctl --set previews delete all
    

    Then open your project, build it and try reloading the preview.

    Login or Signup to reply.
  3. 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...
    

    XCode preferences

    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search