简体   繁体   中英

iPhone - Core Data crash on migration

I have problems, when i install app from Xcode all works but if I build app and install it from iTunes I have an error with the database at launch. This happens only than i have changes in the core data model and need to migrate to a new version. At first launch at crashes with message:

Thread 0:
0   libSystem.B.dylib               0x00034588 pwrite + 20
1   libsqlite3.dylib                0x000505ec _sqlite3_purgeEligiblePagerCacheMemory + 2808
2   libsqlite3.dylib                0x000243d8 sqlite3_backup_init + 7712
3   libsqlite3.dylib                0x000244ac sqlite3_backup_init + 7924
4   libsqlite3.dylib                0x0000d418 sqlite3_file_control + 4028
5   libsqlite3.dylib                0x000228b4 sqlite3_backup_init + 764
6   libsqlite3.dylib                0x00022dd0 sqlite3_backup_init + 2072
7   libsqlite3.dylib                0x000249a8 sqlite3_backup_init + 9200
8   libsqlite3.dylib                0x00029800 sqlite3_open16 + 11360
9   libsqlite3.dylib                0x0002a200 sqlite3_open16 + 13920
10  libsqlite3.dylib                0x0002ab84 sqlite3_open16 + 16356
11  libsqlite3.dylib                0x00049418 sqlite3_prepare16 + 54056
12  libsqlite3.dylib                0x00002940 sqlite3_step + 44
13  CoreData                        0x00011958 _execute + 44
14  CoreData                        0x000113e0 -[NSSQLiteConnection execute] + 696
15  CoreData                        0x000994be -[NSSQLConnection prepareAndExecuteSQLStatement:] + 26
16  CoreData                        0x000be14c -[_NSSQLiteStoreMigrator performMigration:] + 244
17  CoreData                        0x000b6c60 -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1040
18  CoreData                        0x000aceb0 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 92
19  CoreData                        0x000ad6f0 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 72
20  CoreData                        0x000ac9ee -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 880
21  CoreData                        0x0000965c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 1328

At next launches app doesn't loads data from database.

Are you copying your database.sqlite file from the Resources folder to the apps Documents folder? You should do that on the apps first launch (and after that, check that there's a file in place so you don't overwrite it).

Are you sure it's a "crash" and not a xxx failed to launch in time error? Migration often takes several seconds, and it could be longer than the amount of time Apple gives you for initialization. You may have to migrate in the background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM