Chapter 6: "A complex mapping model"

hi

I am having trouble with “A complex mapping model” section (the “UnCloudNotesMappingModel_v3_to_v4” part)
I followed all the steps as described in the book but I end up getting the following error:
(I did not include the whole log because it was too long)


2017-10-20 11:23:49.729680+0900 UnCloudNotes[57025:3975770] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/wayneohm/Library/Developer/CoreSimulator/Devices/8C4EDB2E-828F-44BA-B53E-1F7DE9EDE391/data/Containers/Data/Application/17491065-50A1-490D-AE9D-E25D191EB12A/Library/Application%20Support/UnCloudNotesDataModel.sqlite options:{
NSInferMappingModelAutomaticallyOption = 0;
NSMigratePersistentStoresAutomaticallyOption = 1;
} … returned error Error Domain=NSCocoaErrorDomain Code=134140 “(null)”


fetch request templates {
}, reason=Can’t find mapping model for migration} with userInfo dictionary {
destinationModel = "(<NSManagedObjectModel: 0x600000284bf0>) isEditable 0, entities {\n Attachment = "(<NSEntityDescription: 0x600000156790>) name Attachment, managedObjectClassName UnCloudNotes.Attachment, renamingIdentifier Attachment, isAbstract 0, superentity name (null), properties {\n dateCreated = \"(<NSAttributeDescription: 0x6000000ee900>), name dateCreated, isOptional 0, isTransient 0, entity Attachment, renamingIdentifier dateCreated, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), …

fetch request templates {
}, reason=Can’t find mapping model for migration}: file /Users/wayneohm/Documents/Books/Raywenderlich/Core_Data_by_Tutorials_v4/06-versioning-and-migration/v2/UnCloudNotes/CoreDataStack.swift, line 85

I thought I might have missed a step or two or I opened the project file of the “v4” folder of the source code downloaded from raywenderlich.com and tried again only to end up with the same error message when I ran the compiled code.
(by the way, I made sure that I downloaded the latest course material, v4.01)

does anyone have any idea why this happening??

thanks.

I am having this problem in version 5.0 as well. I think maybe we missed a step along the way. If I find it, I’ll post here.

Ok, so there must have been something wrong with the mapping file, UnCloudNotesMappingModel_v3_to_v4.xcmappingmodel.

I right-clicked the file in the project browser and deleted it, and recreated it from the Mapping model section.

This seemed to fix things and now it migrates correctly. I hope that helps.

1 Like

@afinque Thank you for sharing your solution - much appreciated! :]