Adding an entity to a Core Data model prevent Canvas Preview to show

Hello,

I have a SwiftUI application with a Core Data model. This model contains some entities, with properties. The canvas is working as expected, showing the preview.

But whenever I add a new entity, event without any property, the canvas fail to show the preview (event a basic view with only a text view in it). The error message is the following:

Cannot preview in this file - The operation couldn't be completed. Transaction failed. Process failed to launch.

I tried to clean my cache, the derived data folder, reset the simulators, etc. When I click on Diagnostics, here is the message:

Error Domain=FBProcessExit Code=4 "The process crashed." UserInfo={NSLocalizedFailureReason=The process crashed., BSErrorCodeDescription=crash, NSUnderlyingError=0x600002f29dd0 {Error Domain=signal Code=4 "SIGILL(4)" UserInfo={NSLocalizedFailureReason=SIGILL(4)}}}

RemoteHumanReadableError: The operation couldn’t be completed. Transaction failed. Process failed to launch. (process launch failed)

BSTransactionError (1):
==error-description: Process failed to launch.
==precipitating-error: Error Domain=FBProcessExit Code=4 "The process crashed." UserInfo={NSLocalizedFailureReason=The process crashed., BSErrorCodeDescription=crash, NSUnderlyingError=0x600002f29dd0 {Error Domain=signal Code=4 "SIGILL(4)" UserInfo={NSLocalizedFailureReason=SIGILL(4)}}}
==NSLocalizedFailureReason: Transaction failed. Process failed to launch. (process launch failed)
==transaction: <FBApplicationProcessLaunchTransaction: 0x60000186d960>
==error-reason: process launch failed

Any idea why I have that?

Thanks,
Axel

PS: I'm using Xcode 12 beta 6 (also tried on beta 5). I'm on macOS Big Sur (20A5364e).
Answered by Developer Tools Engineer in 632251022
Howdy,

Glad you were able to fix your issue, and I believe you reached the right conclusion that it was caused by a the currently installed version of the app having an old version of the data model, and you didn't have migration code to handle updating it to the current data model so it was crashing on launch. simctl has a convince for clearing out the preview sim's by using xcrun simctl --set previews delete all
I fixed my issue with the following steps:
  1. I deleted the preview canvas simulator in: ~/Library/Developer/Xcode/UserData/Previews/Simulator Devices/

  2. I used this command line in Terminal: killall -9 com.apple.CoreSimulator.CoreSimulatorService

  3. I restarted Xcode

The preview canvas probably had the old version of the data model.
Accepted Answer
Howdy,

Glad you were able to fix your issue, and I believe you reached the right conclusion that it was caused by a the currently installed version of the app having an old version of the data model, and you didn't have migration code to handle updating it to the current data model so it was crashing on launch. simctl has a convince for clearing out the preview sim's by using xcrun simctl --set previews delete all
Thanks for sharing alpennec, I had this issue today running Xcode 12.3 (12C33) with the same error.

The command recommended by the Frameworks Engineer resolved the issue for me; thanks for sharing!

Just an FYI for the next dev, this happened despite being in the early stages of defining Core Data entities (no data had been persisted to the store yet, just in-memory preview data for the canvas).

Anybody have a good workflow for setting up entities without causing issues?
Adding an entity to a Core Data model prevent Canvas Preview to show
 
 
Q