1
votes

I have an old core data version with Allows external storage in Binary data. And i have created a new one where Allows external storage was unchecked. When i tried to launch my app i got an error:

Unresolved error

Error Domain=NSCocoaErrorDomain Code=134140 "The operation couldn’t be completed. (Cocoa error 134140.)" UserInfo=0xbd5cd20 {reason=Can't find or automatically infer mapping model for migration, destinationModel=...

Then I have created a new file in my project - Model.xcmappingmodel. I have selected source data model and target data model.

After that i see

NSPersistentStoreCoordinator error: NSPersistentStoreCoordinator _coordinator_you_never_successfully_opened_the_database_schema_mismatch

1

1 Answers

0
votes

For future context ... writing to CoreData's external storage is broken as of iOS 12. My solution was based off Drew McCormack's comments on Twitter.

It's worth noting that only writing is broken, reading remains functional.

Create a new property eg «original property name»Internal with the same type but with Allows external storage box unchecked.

You now have two options:

  • Migrate everything on initial startup of the app - ie fetch all objects with a predicate like this «original property name»Internal == NULL && «original property name» != NULL and move the data across (I did this).
  • Migrate on the fly ie use the two properties in parallel but only write to «original property name»Internal (while niling «original property name»)

Worth noting one last time that your customer's data is safe until they update it. Tred carefully but you should be fine.