LoginSignup
3
1

More than 3 years have passed since last update.

Xcode11アップデート後にRealmのエラーでアプリ起動できなくなった際の対応

Posted at

概要

「Xcode11にアプデしたらアプリ起動しなくなりました」

と取引先から連絡が入ったので急ぎ対応しました。
(アップデートはまだしないでおこうと思ったのだが。。)
Xcodeの更新をいつもサボり気味でしたので、これを機に備忘録として対応内容をまとめます。

環境

  • iOS 12.4
  • Xcode 11.0
  • Swift4

不具合内容

これまでXcode10.3で動いていたアプリを、Xcodeのアップデートだけした後にビルドし直して起動しました。
ビルドは成功しましたが以下のエラーが。。

Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'identity' does not exist on object 'RealmSwiftPermissionUser''

ん?RealmのPrimary keyがない?
いや、、ちゃんとあるはずだけど。。。

対応

CocoaPodsで入れていたRealmが3.11系と古めだったので、最新バージョン3.19.0に更新したら直りました!
細かい原因はわからないままですが、マイグレーションかなにかで落ちたのかな?

Podfile書き換えてインストールし直すという方法が上がっていたのでこちらで対応しました。
(SwiftPackageManagerで導入している方は下記サイトを参考)

Podfile
pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
pod install

ちなみに、普通にコマンドでアップデートだけでも大丈夫でした。
ただ他ライブラリも全部更新されてしまうので要注意です。。

pod update

参考

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