iosswiftuirealmxcode12mongodb-realm

Xcode Preview crashes because of RealmSwift model changes


I am developing an app with SWIFTUI, RealmSwift and Xcode 12.4 Along with development, Realm data model changes, eg. some values are removed, some are added...

When I make changes on the data model, I simply delete my app on my device and re-install it to avoid crash derived from Realm migration issue. Now the problem is, Xcode Preview crashes because of the same migration issue and I have no idea how to do a fresh re-build for the Xcode Preview.

Below is the DiagnosticReports Xcode gave me.

Migration is required due to the following errors:

  • Property 'A' has been removed.
  • Property 'B' has been added.

Realm migration for a Preview? It doesn't make sense!

I tried cleaning build, deleting derived data, reboot... without luck. There should be some way to handle Realm model changes for Preview provider.

Please somebody guide me what should I do to get my Preview back.


Solution

  • I soloved my problem based on this forum.

    I got my XCode Preview back.

    Seems like Core Data has similar sort of issue of mine.

    To start from a fresh slate you can use the terminal app and run xcrun simctl --set previews delete all