core-data-migration

Preventing a CoreData crash for upgrading users

倖福魔咒の 提交于 2019-12-06 15:46:41
I built an app about a year and a half ago that I'm coming back to. It was the project I cut my Swift teeth on and obviously a lot has changed since then, both in the language and my Swift abilities. Yesterday for the first time, I updated my single CoreData model to add an optional string attribute. I did the file generation bit and made sure in the inspector column the new data model is appropriately selected. On my Simulator and testing devices, I need to delete the old version of the app to install the new version or I get a crash. I assume that's just part of the development environment

Core Data migration failure between NSPersistenceFrameworkVersions 251 and 358

爱⌒轻易说出口 提交于 2019-12-06 14:00:58
问题 I have what appears to be a bug with Core Data in OS X 10.7.1. My data store (NSSQLiteStoreType) is not being automatically migrated correctly. As a side note the exact same Core Data models are used by an iOS version of the app. -> Here is what appears to be happening. Up until the latest release everything has been working fine -- I have 14 revisions of the model -- model 13 has been shipping for quite some time without incident. Recently I updated my app and added a new model so I am at 14

Core Data lightweight migration crash

◇◆丶佛笑我妖孽 提交于 2019-12-06 11:32:42
I updating my database with a lightweight migration. If I do the update on my device through xcode in debug mode everything runs fine. If I load the app through iTunes as a archive file it will crash before loading the rootViewController. This only happens with my large test database >100mb. I don't get anything useful in the crash log and am not sure what to do with this. His is the only relevant line I can find in the crash log. Unknown thread crashed with unknown flavor: 5, state_count: 1 Normally this would be reflected in the crash report (It would say something about failing to launch in

Xcode Core Data: Change existing XML to Sqlite (NSXMLStoreType to NSSQLiteStoreType)

风格不统一 提交于 2019-12-06 11:30:54
On my first app I used within my persistant store coordinater a NSXMLStoreType. [storeCooordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:storeURL options:options error:nil]; Now, I like to change to a NSSQLiteStoreType: [storeCooordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:nil]; The app crashes, if I simply change the store type. So what I have to do? May I have to do once: check if the old store exists and if yes convert it to sqlite and delete afterwards the old xml store? I have no idea how to convert

Must I enable versioning in my first release in order to use lightweight migration in subsequent releases?

自作多情 提交于 2019-12-06 09:08:26
My fear is the change of the data model in subsequent releases. I created a new xcdatamodel file in Xcode which is not versioned by default. I know you can click somewhere and make it "the first version". In the Groups and Files tree the xcdatamodel file gets a thick black arrow on the left side which you can click to see all the versions inside. My file does not have that thick arrow so is not versioned. Does this cause big problems later? Is it needed to version it right from the start to make lightweight migration work later? Once the app is shipped to users this can't be changed anymore.

How many migration steps does Core Data lightweight migration have?

和自甴很熟 提交于 2019-12-06 05:30:31
I use Core Data and lightweight migration for my iPhone app. Suppose I have created 3 versions of the data model for the app. One user installed the early version of my app and its data model version is still v1. When the user update the app to the latest version which has the data model version v1,v2 and v3, what happened during the update? The sqlite database migrate from v1 to v2 first and then migrate from v2 to v3? Or it just jump from v1 to v3? Internally, I believe Core Data lightweight migration will apply the changes to each subsequent version in order, but for your purposes you can

how do i remove coredata from iphone

妖精的绣舞 提交于 2019-12-05 19:34:47
You know how you can Reset the coredata store on an iPhone simulator when you've changed your entity structure? Do I need to perform a similar process when I've created a new version of my core data store that is different from what I last ran on my iPhone? If so, how, please? Thanks Just for convenience, until you code a way to remove the persistent store through your app, you can just delete the app off the phone. (Hold your finger on the home screen until icons get wiggly, then click the x on your app.) Then with your phone connected to your Mac, choose Product > Run in XCode and it will

Enable saving of document NSManagedObjectContext immediately?

蹲街弑〆低调 提交于 2019-12-05 13:21:58
Starting from the standard Xcode Document-based Application w/ CoreData template on 10.7, I'm experiencing some frustrating behavior. I'm sure it's something simple that I'm overlooking. Let's say in my NSPersistentDocument subclass, I have something like this, hooked up to a button in the window: - (IBAction)doStuff:(id)sender { NSEntityDescription* ent = [[self.managedObjectModel entitiesByName] valueForKey: @"MyEntity"]; NSManagedObject* foo = [[[NSManagedObject alloc] initWithEntity: ent insertIntoManagedObjectContext: self.managedObjectContext] autorelease]; [self.managedObjectContext

iOS Core Data + iCloud error for addPersistentStoreWithType: You don’t have permission to save the file “store” in the folder

柔情痞子 提交于 2019-12-05 07:40:53
问题 I've created a Core Data project from scratch, the only change I made is that where the persistent coordinator is adding a store, I'm providing a NSPersistentStoreUbiquitousContentNameKey option: coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: [NSPersistentStoreUbiquitousContentNameKey : "coreDataiCloudTestStore"]) and I'm inserting and saving a new managed object at launch. When at launch there is no iCloud account logged in, no problems.

Skipping painful migration with Core Data and move to the new data model

瘦欲@ 提交于 2019-12-05 05:29:11
问题 I'm spending a lot of time massaging core data into a new migration when I don't even care about the old data. Instead of dealing with the hassle of mapping models each time I change my data model, is there a way to just delete all existing data and jump to the new data model? 回答1: Yep, just delete the store file and recreate it. I often (at least in development) have my code try an auto migration, and if that fails, blow away the store and start over: // storefile is an NSURL to the store