Re: Sharing a persistent store between iOS and Mac
Re: Sharing a persistent store between iOS and Mac
- Subject: Re: Sharing a persistent store between iOS and Mac
- From: Heath Borders <email@hidden>
- Date: Fri, 26 Aug 2011 09:19:23 -0500
I've done something similar in two of my projects. However, I only shared
the sqlite file, not the momd.
I created a command-line build tool, and generated a sqlite coredata store
with it. Then I copy the sqlite into my iOS project and add it to the Copy
Bundle Resources phase. I do NOT copy the momd. I reference the same
xcdatamodel file in both projects and each one builds its own copy. Perhaps
the sqlite file is shareable but the momd is not?
-Heath
On Aug 25, 2011 3:31 PM, "Fritz Anderson" <email@hidden> wrote:
> iOS 4.3 Simulator, Xcode 4.1, Lion 10.7.1
>
> I'm having trouble generating a Core Data store and opening it in an iOS
app (in the Simulator so far).
>
> My iOS app has to initialize a large, read-only dataset — a 12,000-word
vocabulary with definitions. In my early drafts, with 6000 words, I had it
parse a text file, but that took alarmingly long, and the watchdog timer
would probably kill it if I attempted the full dictionary.
>
> So if I'm initializing an SQLite Core Data store anyway, why not do so at
build time, with a command-line tool on the Mac side?
>
> So I have two targets. They share one managed-object class and a data
model. The builds for both compile the data model into a .momd. It's not the
same momd, but VersionInfo.plist in both is identical. The command-line tool
takes the .momd and the vocabulary text, and produces vocab.sqlite in
SRCROOT. Using Navicat for SQLite Lite, I verified that the contents of the
file are (as far as I can tell) what I expect.
>
> The iOS target copies vocab.sqlite as a resource. I verified (by eye and
by an assertion in code) that it is in the .app bundle. I reviewed the build
logs and verified that the .sqlite file came from the place to which the
command-line tool wrote.
>
> I get "The model used to open the store is incompatible with the one used
to create the store" when the iOS app tries to add vocab.sqlite to the
persistent store coordinator.
>
> There is only one .momd in the .app bundle. The command-line tool takes a
.momd as an argument; I've tried pointing it at the .momd inside the bundle;
still "incompatible."
>
> From everything I know to check, I'm doing this right. I've found nothing
to suggest you can't put a Mac-generated store into an iOS app, and much to
suggest that you should. I'm stymied. What should I try next?
>
> — F
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden