0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Realm-SwiftでschemaVersionを変えるだけでクラッシュする

Last updated at Posted at 2024-04-30

エラー内容

Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=16 "Database has an unsupported version (24) and cannot be upgraded" UserInfo={Error Name=UnsupportedFileFormatVersion, NSLocalizedDescription=Database has an unsupported version (24) and cannot be upgraded, Error Code=16}

解決方法

Realmのバージョンを最新版に更新したら解決した。
変更前:v10.43.1
変更後:v10.49.2

SPMを使っている場合の更新方法

最新化の手順は File > Packages > Update to Latest Package Versionsを実行する
image.png

詰まったこと

migration周りの失敗だと思いこんでおり、データ構造やmigrationの見直しを行っていたが解決しなかった。
試しにschemaVersionのみ差分を出してみると今回のエラーとなったので、Realm側の更新を疑ったら解決した。
(いつからかは不明だが、migrationはリリース以降触れていなかったので顕著化していなかったのかなと思われる)

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?