0

I am Getting crash in app upgrade scenario. It gives below error and warning. But this issue happens only when I have AppStore build installed and on top of that I install my new testflight build. If I install developer build on AppStore build, than it works fine.

Error:

[__NSArrayM UTF8String]: unrecognized selector sent to instance

Warning: An RLMRealm instance was deallocated during a write transaction and all pending changes have been rolled back. Make sure to retain a reference to the RLMRealm for the duration of the write transaction.

It crashes straight away when you tap app icon, So, I dont have any stack trace.

Realm version: 0.96.3 & Xcode version: 7.3

Below is my migration code for that.

RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
    config.schemaVersion = 3;

    if (oldSchemaVersion < 2)
    {
        [migration enumerateObjects:DB_Class1.className
                              block:^(RLMObject *oldObject, RLMObject *newObject) {
                                  newObject[@"thisIsArray_1"] = nil;
                              }];
        [migration enumerateObjects:DB_Class2.className
                              block:^(RLMObject *oldObject, RLMObject *newObject) {
                                  newObject[@"thisIsInt_1"] = 0;
                                  newObject[@"thisIsInt_2"] = 0;
                                  newObject[@"thisIsInt_3"] = 0;
                              }];            
    }

All of the above newObjects are added in this version only.

Update 1: I can see deleteRealmIfMigrationNeededfor android. Is there any eqvivalent in iOS? I only found deleteAllObjects. If so, thn I can simply delete my old realm data and save new one.

Thanks.

JiteshW
  • 2,195
  • 4
  • 32
  • 61
  • 1
    see this once it helps you https://github.com/realm/realm-cocoa/issues/3422 – Anbu.Karthik May 13 '16 at 05:24
  • @Anbu.Karthik, Yes, based on that I had upgraded realm, but couldnt solve – JiteshW May 13 '16 at 05:39
  • The error message simply says that `UTF8String` is sent to an `NSArray` object rather than the expected `NSString` object – vadian May 13 '16 at 10:16
  • But it dosent happen in developer build. My data remains the same for developer and release build, but, this happens only during release build. – JiteshW May 14 '16 at 06:19

1 Answers1

1

Realm Cocoa added the deleteRealmIfMigrationNeeded option (on RLMRealmConfiguration) in version 0.102.0. This should allow you to sidestep your migration issues. See the change notes here.

AustinZ
  • 1,787
  • 1
  • 13
  • 21