how to resolve "no such table: Z_METADATA" error for first deploy to an IOS device
Asked Answered
F

1

6

The first deployment to an IOS device for my application is crashing as I'm getting a: "'no such table: Z_METADATA'" error. I have copied the SQLite file across from my device and opened it up in a SQLite browser and I see no tables in it.

It seems to occur in the code (I took from the Apple example) which sets up the database:

 NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataProjectTemplate.sqlite"];
[__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]  // Errors out here

And I get the error:

Unresolved error Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)" UserInfo=0x1905e0 {NSFilePath=/var/mobile/Applications/543D2AA1-2484-4A6B-A694-DCD55B81E224/Documents/CoreDataProjectTemplate.sqlite, NSUnderlyingException=I/O error for database at /var/mobile/Applications/543D2AA1-2484-4A6B-A694-DCD55B81E224/Documents/CoreDataProjectTemplate.sqlite.  SQLite error code:1, 'no such table: Z_METADATA'}, {
    NSFilePath = "/var/mobile/Applications/543D2AA1-2484-4A6B-A694-DCD55B81E224/Documents/CoreDataProjectTemplate.sqlite";
    NSUnderlyingException = "I/O error for database at /var/mobile/Applications/543D2AA1-2484-4A6B-A694-DCD55B81E224/Documents/CoreDataProjectTemplate.sqlite.  SQLite error code:1, 'no such table: Z_METADATA'";
}
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.1 (8G4)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).

So I guess my questions would include:

  1. How can I resolve this?
  2. Is the Apple code I'm using supposed to create the Z_METADATA table? (if so why isn't it there)

thanks

UPDATE: I tried manually deleting the sqlite file on the device and after this the application deployed fine. Do I perhaps just treat what happened as an anomaly perhaps?

Felicidadfelicie answered 9/4, 2011 at 22:5 Comment(4)
There's an existing question that might provide some hints - #3534374Doublejointed
yeah - I read through this one before I posted - unfortunately it didn't helpFelicidadfelicie
UPDATE: I tried manually deleting the sqlite file on the device and after this the application deployed fine. Do I perhaps just treat what happened as an anomaly perhaps?Felicidadfelicie
Yes it's most likely an anomaly. Core Data should take care of all this stuff for you.Hapless
F
0

I tried manually deleting the sqlite file on the device and after this the application deployed fine.

(Probably therefore treat this as an anomaly)

Felicidadfelicie answered 11/4, 2011 at 3:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.