Reputation: 53
I am trying to make a lightweight migration in Core Data. I just to want to add a new attribute in an existing Entity. New model version is created for this purpose. Every time the app runs, it crashes at runtime immediately after launch with this message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use fetch request with fetched property description (entity model mismatch).'
Also, I have enabled SQL debug flag and before the crash I get this:
CoreData: annotation: Disconnecting from sqlite database.
Notes:
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x1aca24878 __exceptionPreprocess
1 libobjc.A.dylib 0x1c0f7ac50 objc_exception_throw
2 CoreFoundation 0x1ac91d4a4 -[NSCache init] <- CRASH HERE
3 CoreData 0x1b2c4a984 -[NSFetchedPropertyDescription setFetchRequest:]
4 CoreData 0x1b2c4aab4 -[NSFetchedPropertyDescription _createCachesAndOptimizeState]
5 CoreData 0x1b2c3d608 -[NSEntityDescription(_NSInternalMethods) _createCachesAndOptimizeState]
6 CoreData 0x1b2c8305c -[NSManagedObjectModel(_NSInternalMethods) _createCachesAndOptimizeState]
7 CoreData 0x1b2c83f94 -[NSManagedObjectModel(_NSInternalMethods) _setIsEditable:optimizationStyle:]
8 CoreData 0x1b2b30e40 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:]
9 CoreData 0x1b2c9e494 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke
10 CoreData 0x1b2cab6f4 gutsOfBlockToNSPersistentStoreCoordinatorPerform
11 libdispatch.dylib 0x1ac618db0 _dispatch_client_callout
12 libdispatch.dylib 0x1ac627428 _dispatch_lane_barrier_sync_invoke_and_complete
13 CoreData 0x1b2c9b268 _perform
14 CoreData 0x1b2b30744 -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]
15 CoreData 0x1b2c9d3f8 -[NSPersistentStoreCoordinator _doAddPersistentStoreWithDescription:privateCopy:completeOnMainThread:withHandler:]
16 libdispatch.dylib 0x1ac61724c _dispatch_call_block_and_release
17 libdispatch.dylib 0x1ac618db0 _dispatch_client_callout
18 libdispatch.dylib 0x1ac61bddc _dispatch_queue_override_invoke
19 libdispatch.dylib 0x1ac62993c _dispatch_root_queue_drain
20 libdispatch.dylib 0x1ac62a120 _dispatch_worker_thread2
21 libsystem_pthread.dylib 0x1f5e3c7c8 _pthread_wqthread
22 libsystem_pthread.dylib 0x1f5e4375c start_wqthread
Any help is much appreciated, as I cannot update my application in this state.
Upvotes: 0
Views: 296
Reputation: 53
It seems that there was a "bad" model version in my data model. As I explained in my initial post I have 33 model versions. After a technical question I raised in Apple Code Level Support, an engineer guided me to delete one by one the past versions as he discovered that one of them is the responsible for the crash after keeping only the last two. Eventually, he was correct as I found that model version 15 was the culprit. The issue is most probably an internal bug of Core data and I have opened a Feedback ticket as well. Let's hope this will be resolved in future releases of XCode. For now, I deleted all the past versions - culprit included - as I don't need them anymore and the crash has disappeared.
Upvotes: 1