Wired Error When Turning off iCloud in Core Data: Updating from App Store Version to TestFlight/Xcode Version

Say I have an app, version 1.0 using iCloud with Core Data. I want to turn iCloud off in version 2.0. I use the methods described here.

  • When I install version 1.0 from Xcode, then update to version 2.0 from Xcode, it works well.
  • When I install version 1.0 from TestFlight, then update to version 2.0 from TestFlight, it also works well.
  • When I install version 1.0 from App Store, then update to version 2.0 from TestFlight, it fails.
  • When I install version 1.0 from App Store, then update to version 2.0 from Xcode, it also fails, this time, I can see the error log.
  • When I install version 1.0 from TestFlight, then update to version 2.0 from Xcode, it also fails, the error log is the same, as below:

2017-11-05 00:05:23.186 MyApp[6155:2915079] CoreData: error: -addPersistentStoreWithType:SQLite configuration:PF_DEFAULT_CONFIGURATION_NAME URL:file:///var/mobile/Containers/Data/Application/0D43665A-764E-4553-A0F0-C6439C51AC69/Documents/MyApp.sqlite options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentStoreRemoveUbiquitousMetadataOption = 1;
NSPersistentStoreUbiquitousContentNameKey = MyApp;
“_NSNotifyObserversOfStoreChange” = 0;
} … returned error Error Domain=NSCocoaErrorDomain Code=134080 “An error occurred while opening the persistent store.” UserInfo={NSUnderlyingException=Can’t add the same store twice} with userInfo dictionary {
NSUnderlyingException = “Can’t add the same store twice”;
}

I wonder whether this error comes from code itself, or from the test method described before.

And when I install version 1.0 from App Store, then update to version 2.0 from App Store, will it succeed?