Search code examples
ioscore-datamigrationmagicalrecord

Core data auto migration is not working


Folks,

I need some help on core data migration and here is the description about situation.

  1. I have a existing iOS app which is using core data for offline support.
  2. Current version of the app in the store is 1.1 and current version of core data model in the app store is 11 (Model11.xcdatamodel).
  3. Now I am releasing a new version (1.1.1) to the app store and there are major works have happened. Also one of the entity has got a new attribute added in core data.
  4. Before making changes to model file, I added new model file (Model12.xcdatamodel) by keeping Model11.xcdatamodel as a base.
  5. Made Model12.xcdatamodel as a current version.
  6. Added new attribute in one of the entity to support on of the feature, made changes in mode etc.
  7. After this I made Model11.xcdatamodel whose type as "version core data model" from Xcode utility window (right side).
  8. Installed 1.1v from app store, did login and on top of this I created 1.1.1v app in release mode and installed.

But app starts crashing and it says the store URL is empty, here is the log from device.

Jan 19 13:04:50 iPod MyApp[15856] <Error>: Magical Record Stack: Current Default Core Data Stack: ---- 
    Model:           {
        BroadcastMessage = <6fa959c6 514f4c53 e53e7fd7 28585c56 6d4da4ad ba56c2c4 d92bef6e debadfd4>;
        Data = <92870bec c4a8794e 293dcbe9 93282d69 cb675039 cb9b9bf6 8dda6359 34697663>;
        Event = <de060947 8ec9f2bb 80e341eb 787e7eec 7cc2a09f 356e511c 7d515ca5 130690fe>;
        InvitedFriend = <1e041915 6931f26e fd325666 299adf13 5fa2a735 b16b5faf cc0c7de1 1792c97f>;
        MAnswer = <5c06b689 b0497f14 65e550d0 1bd30779 08056f42 a6361f71 4e0eb2e5 67127d66>;
        MQuestion = <96d6e2a6 b96f1371 2c52e719 ca6a0cbd 7957e63a 4a6ccbe8 049e8818 f9ec5d2d>;
        MUser = <af239067 1b3fb3d9 d63b6536 e0e411a8 6ff5f02e db5d7c01 968a4835 4f361610>;
        NotificationSettings = <75be9f25 cfb5f63e 9f717160 9b389386 8fb9d7e2 093648ac beff79dd b0c8181b>;
        RecentContact = <0eaf2696 94c73a4e 9155b3aa c98bf623 51165db6 c1a1472c 2178c3d0 654c0dac>;
    }
    Coordinator:     <NSPersistentStoreCoordinator: 0x15e883a0>
    Store:           (null)
    Default Context: <NSManagedObjectContext (0x15e96c70): *** DEFAULT ***> on *** MAIN THREAD ***
    Context Chain:   

    - DEFAULT (0x15e96c70) (*)
    - BACKGROUND SAVING (ROOT) (0x15e99000) 
Jan 19 13:04:50 SB-iPod Medusa[15856] <Error>: Store2 URL after creation (null)

store URL is coming as NULL. I am not sure why this is happening.

I get a valid URL if I run in the debug mode and note that I am using Magical Records for core data.

I have followed what is mentioned in this link https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOM.html But this is not working

Can some tell me why this migration is getting failed and how can I fix this?


Solution

  • Finally I ended up in using manual migration and not auto/light migration. This solved the problem

    Pls check this link which is very useful https://github.com/magicalpanda/MagicalRecord/issues/466