RLMException: 'Primary key property 'serial' does not exist on object 'Book' Migrating to Swift 4

realm swift
realm relationships
realm in-memory
realm swift package manager
realm list swift
realm notifications
realm swift primary key
swift db

I'm running into this issue with Realm on iOS using Swift 4 compilation, where on startup the app crashes with the following message

RLMException', reason: 'Primary key property 'serial' does not exist on object 'Book''

I saw similar error messages, but not the same one. This is what my object looks like

import Foundation
import RealmSwift

class Book: Object {
    dynamic var serial: String = ""
    dynamic var title: String = ""
    dynamic var pages: Int = 0
    dynamic var genre: String = ""

    override static func primaryKey() -> String? {
        return "serial"
    }
}

When I checked the default.realm file through the Realm Browser app, I noticed that the entries only have a # (0,1,2) and no data in it. If I comment out the primary key, it runs, but nothing is stored in Realm for this object. Can't figure out why it's crashing!


Although it doesn't necessarily about migration, there's an issue with iOS 13 and Xcode 11 which may cause this problem. All String properties of Realm classes with a default String value set are disregarded somehow. You can fix this by updating to the latest version (currently 3.20.0) and than on Xcode: Product -> Clean Build Folder.

If you're using cocoa-pods, do this:

Open your project's Podfile, and replace RealmSwift line with:

pod 'RealmSwift', '~> 3.20.0'

Then, open terminal on the project's folder and:

pod repo update
pod install

Hope that helps.

Terminating app due to uncaught exception 'RLMException , Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an​  *** Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole'' *** First throw call stack: ( 0 CoreFoundation 0x000000010b940b6e __exceptionPreprocess + 350 1 libobjc.A.dylib 0x000000010820bf57 objc_exception_throw + 48 2 Realm 0x000000010919f1d3


In Realm, the properties of your model have to have the @objc dynamic var attribute, that is what I was missing.

From Realm website:

Realm model properties must have the @objc dynamic var attribute to become accessors for the underlying database data. Note that if the class is declared as @objcMembers (Swift 4 or later), the individual properties can just be declared as dynamic var.

RLMException", reason: 'The Realm is already in a write transaction , Hello! I'm doing an object property update here, and I get the app crash with the error "RLMException", reason: 'The Realm is already in a write  Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.' #5472 ikyh opened this issue Nov 13, 2017 · 3 comments


import Foundation
import RealmSwift

class Book: Object {
   @objc dynamic var id : Int = 0
   @objc dynamic var serial: String = ""
   @objc dynamic var title: String = ""
   @objc dynamic var pages: Int = 0
   @objc dynamic var genre: String = ""

    override static func primaryKey() -> String? {
        return "id"
    }
}

Realm object has been deleted or invalidated, Terminating app due to uncaught exception 'RLMException', reason: 'Realm accessed from incorrect thread.' All I'm trying to do right now is to  Ergun, Before quitting the application if you do a sync() does it make a difference? Also does calling push() (which should save data from local to remote) make any difference?


In my case, adding @objMembers on top of the class name fixed it

Ex:

@objcMembers
internal final class Recipient: Mappable {
dynamic var transferID: String = ""

How to fix Terminating app due to uncaught exception, Currently Swift doesn't show where a RLMException happened. In Realm/​RLMUtil.mm:266, there is the definition for RLMException. If you change the code to  ‘Migration is required for object type ‘NotSureItem’ due to the following errors: – Property ‘text’ is missing from latest object model. – Property ‘title’ has been added to latest object model. – Property ‘textDescription’ has been added to latest object model.’ Here its my code:


Change Realm in Pod file with the new version of Realm like :

From

pod 'RealmSwift', '~> 3.11.0'

TO

 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

make sure about the all fields define like :

 @objc dynamic var myID: String!

Realm Compiled Error in Xcode 11, How to fix this problem Terminating app due to uncaught exception '​RLMException', reason: 'Realm accessed from incorrect thread.' , I spent 2 days looking for  'RLMException', reason: 'Index is out of bounds.'. GitHub Gist: instantly share code, notes, and snippets.


Create reactive mobile apps in a fraction of the time, Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'id' does not exist on object 'ToDoItem''**. RLMException, Migration is required for object type (4) I have an object NotSureItem in which I have three property 'title' whose name is renamed from 'text' and textDescription which I had added later and a dateTime property. Now when I am going to run my app it crashes when I want to add something to these properties.


RLMException: object has been deleted or invalidated, It must be // higher than the previous version (oldSchemaVersion) or an RLMException is thrown setSchemaVersion(1, Realm.defaultPath, { migration  The Oracle Release Management Exception Report can be customized to include several extra data elements stored in the exception table. Occurrences of a Specific Exception: In some cases, exceptions recur on multiple schedule lines that have the same attribute that triggered the exception.


RLMException: primary property `name` on , RLMException: object has been deleted or invalidated. Categories: Community content may not be verified or up-to-date. 4/24/15 Zsombor  Port Exceptions: If you are opening ports on your firewall you will need to open two for the RLM server - one for the main port that is specific on the HOST line of the license (default value of 4101) and one for the ISV vendor daemon part of the server.