small medium large xlarge

Back to: All Forums  Core Data
14 Feb 2010, 13:00
Fernando López (6 posts)


I have implemented v2_to_v3.xcmappingmodel and carefully copied rules and custom policy classes from the book examples to my example. However I end up with this error: “Recipes_AppDelegate:persistentStoreCoordinator An error occured during persistent store migration”.

Clearly I have made a mistake copying rules :-(. The error message is not quite explanatory. How could I debug the execution of my migration rules to determine where is my error?

Sincerely: iFernando

14 Feb 2010, 17:51
Marcus S. Zarra (284 posts)

Break on @obj_exception_throw@ and unwind the error using @po@ (print object) in the debugger. You can use that to access the @userInfo@ property of the @NSError@ and discover what is actually wrong. For example you can execute:

po [NSError userInfo]

In the debugger and get a peak at what is in the @userInfo@ of the error. You can then make subsequent calls inside of the the userInfo to discover the details of the error.

14 Feb 2010, 19:16
Fernando López (6 posts)

Ok thank,

I am reporting what I did to identify the problem, as this is not trivial at all.

  1. Set a breakpoint on the exception:

@b objc_exception_throw@

  1. Backtracing we observe that the exception was throw inside @NSEntityMapping(_NSInternalMethods) _migrationPolicy@.

@0x00007fff83e1be00 <+0032> je 0x7fff83e1be32 <-[NSEntityMapping(_NSInternalMethods) _migrationPolicy]+82>@ @0x00007fff83e1be02 <+0034> callq 0x7fff83e461ec @ @0x00007fff83e1be07 <+0039> lea -0x1379219e(%rip),%rsi # 0x7fff70689c70@ @0x00007fff83e1be0e <+0046> mov %rax,%rdi@ @0x00007fff83e1be11 <+0049> callq *-0x137921a7(%rip) # 0x7fff70689c70@ @0x00007fff83e1be17 <+0055> mov -0x13791f06(%rip),%rsi # 0x7fff70689f18@ @0x00007fff83e1be1e <+0062> mov %rax,%rdi@ @0x00007fff83e1be21 <+0065> xor %al,%al@ @0x00007fff83e1be23 <+0067> callq 0x7fff83e46468 @ @0x00007fff83e1be28 <+0072> test %rax,%rax@ @0x00007fff83e1be2b <+0075> je 0x7fff83e1be59 <-[NSEntityMapping(_NSInternalMethods) _migrationPolicy]+121>@

  1. Set a breakpoint inside this function to detect a class name resolution with @dyld_stub_NSClassFromString@:

@b *0x00007fff83e1be02@ @po $rbx@ @IngredientToIngredient@

And this is the missing class. For some reason Xcode did not include this class in the target of my project.

After fixing up this problem the migration has completed successfully. Unfortunately some core bindings now are reporting problems because the schema changed. I have to figure out how to redo these bindings.

Sincerely: iFernando

You must be logged in to comment