문제

I set up my working Core Data sqlite file for versioning. The versioning setup process created 3 files:

  • foo.sqlite
  • foo.sqlite-shm
  • foo.sqlite-wal

Since then, I can access the Core Data store programmatically (using MagicalRecord), but I can't read any data using either the Firefox add-in (SQLite Manager) or the app SQLiteManager. I'm concerned that when I send the updated app to the App Store, the additional files are not going to go and the app is going to crash.

What do I need to do to make sure new versioning-enabled sqlite files go with the app?

도움이 되었습니까?

해결책

Those are not version-related files, they're SQLite log files. These files get created automatically when write-ahead logging is enabled. That's not the default in iOS 6, but it's possible if you use PRAGMA journal_mode=WAL;. It might or might not be the default in iOS 7 (I have no comment at this time).

I don't know why Firefox and SQLiteManager can't open the file. I speculate that they're both using an old version of SQLite (since WAL is only available as of SQLite 3.7.0). Regardless, they have nothing to do with whether the necessary files are available in your app. You can find out what's included in the app by just looking. The .app is just a directory, really, so take a look inside and see what's there.

다른 팁

If you are using lightweight migration (wich is enabled by passing the right options when you open the store), Core Data takes care of upgrading the schema in-place.

The additional WAL and SHM files are not a result of lightweight migration, but are instead simply produced by SQLite in the “write ahead logging” mode that Core Data puts it into. (An oversimplification is that new data goes into the .wal file until enough accumulates and then it is moved to the .sqlite file.)

Yes, you definitely want to test using Ad Hoc builds for lightweight migration; testing from Xcode is insuffient.

Mike Fikes

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top