Re: how to deploy the sqlite file in my Cocoa application installation
Re: how to deploy the sqlite file in my Cocoa application installation
- Subject: Re: how to deploy the sqlite file in my Cocoa application installation
- From: David Reed <email@hidden>
- Date: Sat, 17 Jul 2010 09:33:43 -0400
On Jul 17, 2010, at 12:32 AM, Wayne Shao wrote:
> Thanks! That is very helpful. I have added a data file in my project as you suggested.
>
> I come from the linux world, where this sort of things are done in installation script or package post-install script.
> I have never released an App on Mac. Is there any concept of App post install script?
>
> I just found a link through google. http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/SoftwareDistribution/Introduction/Introduction.html. I will read it.
Using a software installer for just copying an initialized data file seems overkill and probably won't do what you want if you want multiple users to be able to use your app (i.e., only the user who ran the installer would get the data file). What I'm suggesting is a much simpler process of having the data file be included in your .app bundle and then having your code copy the data file when the program is run rather than doing it during installation of the app so it will happen for each user.
See:
http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/200-Build_Phases/bs_build_phases.html
I use the run script build phase to execute the SQL commands.
/bin/rm -f attend.db
/usr/bin/sqlite3 attend.db < attend.sql
and then make certain the attend.db file (my initialized sql file) is included in the "Copy Bundle Resources" list.
Then in the initialization code for my app, I look for an attend.db file in the user's directory and if not, copy this attend.db file to their directory.
HTH,
Dave
>
> Please let me know if there are other simple samples/docs on this.
>
> Thanks,
> -W. Shao
>
>
> On Fri, Jul 16, 2010 at 5:27 AM, <email@hidden> wrote:
>
> On Jul 16, 2010, at 5:23 AM, Mike Abdullah wrote:
>
> > SQLite is not part of Cocoa, so this is the wrong list. You should either:
> >
> > 1) Find the SQLite docs/list
> > 2) Use Core Data instead
> >
> > On 16 Jul 2010, at 02:39, Wayne Shao wrote:
> >
> >> Hi,
> >>
> >> I am using sqlite in my cocoa application (for regular mac desktop/laptop).
> >>
> >> 1. How do I initialize the sqlite (e.g, make sure empty tables with the
> >> correct schema is put at the right path)
> >> as part of the application installation?
> >> 2. Any documentation on the install/packaging of my application in general?
> >>
> >> Thanks,
> >> --
> >> W. Shao
>
>
> I would think the process of shipping a data file with an app is a fair question for this list. What I do (and I think is recommended) in my iPhone app is to take your default sqlite file (with the tables created) and add it as a resource to your project in Xcode. I take this a slight step farther and have the sql commands be issued as part of a build script to
>
> how can I add things to the build script in XCode?
>
> create the file (that way I can easily modify it later if necessary). Then when your app launches, you check for the existence of the data file in the location your app would put it (such as a folder in the users's ~/Library/Application Support/YourAppName) and if it's not there, copy it from your application's resources to that directory.
>
> HTH,
> Dave
_______________________________________________
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