LoginSignup
0
0

More than 1 year has passed since last update.

【Xcode エラー】個人的に1番簡単に感じた「Migration is required due to the following errors」の解決法

Last updated at Posted at 2023-04-29

下の参考記事を読んだが1番簡単にエラーを解消することができたのは
《参考記事④》の以下の手順。

プライマリーキーを最初指定しないまま使用していた場合に
後からプライマリーキーを指定してしまうと
以下のようなエラーになってしまいます。

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=10 "Migration is required due to the following errors:

これは定義済みのRealmクラス(テーブル定義)と
保存されているRealmオブジェクト(テーブル内のレコード)の定義が
不一致を起こすためです。

この場合は一度アプリ自体をデバイスから削除するか
マイグレーションを使用することで解決できます。

《参考記事①》RealmSwiftのMigration
https://qiita.com/taitai9847/items/2094bf605c2f7fa22e51

《参考記事②》【Swift】Realm利用時に
「Migration is required due to the following errors」というエラーが出る
https://appdev.blitz-time.com/entry/2023/01/11/193843

《参考記事③》【SwiftUI】Realmのマイグレーション方法!
Migration is required due to the following errorsの解決法
https://tech.amefure.com/swift-realm-migration#:~:text=%E5%87%A6%E7%90%86%E3%81%AE%E3%82%84%E3%82%8A%E6%96%B9-,%E3%82%A8%E3%83%A9%E3%83%BC%EF%BC%9AMigration%20is%20required%20due%20to%20the%20following%20errors,%E3%81%8C%E3%81%82%E3%82%8B%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%E3%80%82&text=%E3%81%99%E3%82%8B%E3%81%A8%E3%82%A2%E3%83%97%E3%83%AA%E5%AE%9F%E8%A1%8C%E3%81%95%E3%81%9B%E3%82%8B%E3%81%A8,%E5%81%9C%E6%AD%A2%E3%81%97%E3%81%A6%E3%81%97%E3%81%BE%E3%81%84%E3%81%BE%E3%81%99%E3%80%82

《参考記事④》【SwiftUI】Realmでプライマリーキーの設定方法!UUIDを指定
https://tech.amefure.com/swift-realm-primary-key

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0