3

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.

Vincent Gigandet
  • 918
  • 10
  • 21

1 Answers1

5

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

Vincent Gigandet
  • 918
  • 10
  • 21
  • Thanks for this! This problem haunted me for days. – Nico Dioso May 23 '21 at 16:56
  • Hey, this solution works fine for me. but after some builds, it keeps coming back because schema will be set to 0 again! any solution for this? `Provided schema version 0 is less than last set version 27.` – MrAlirezaa Nov 16 '21 at 08:41
  • Thanks for your answer this solved the problem. But. anyway I didn't found where is the Realm.default database file stored on the preview simulator. – Ezequiel Adrian Aug 09 '23 at 07:03