Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode: how to save files in "documents" folder in compile/build phase (not via "code on run")?

I have a lot of jpeg+png+html files to add to my app, and of course when i "build" it all my resources files are added/included in myApp mainBundle folder.

I'd like to be able to modify via code, in run time, some of my resources, but:

1) we cannot "write" files via code in run-time in mainBundle

2) we can do it just in "documents" folder (or temp, or...)

3) we can copy files in "Documents" folder just via code in run-time

4) we cannot delete the mainBundle files after coping them in "Documents"

but that means that we will have doubled-sized our app, and in big apps (it's my case) this should be a non-sense, we'll have a lot of big files never used again in the mainBundle...

so i wondered if there was a work-around for this problem (is it just me thinking it's a non-sense?) to add files directly in the "Documents" folder in the "build" phase via xCode, or other similar solutions...

ps

one could be to download all files the first time a user use my app via server/internet directly in "Documents" folder, so my app won't be heavy to download via iTunesStore, but of course this will get a lot of time the first time for end-users, and it could be not well accepted, of course...

like image 559
meronix Avatar asked Jul 20 '11 06:07

meronix


1 Answers

Well you can't, since the document directory is created on installing the app. There is no way to do what you want on compile time. Neither you can do it at the install.

Since you needed the file you have to include them in your bundle, i've even included 10MB sqlite database that I copy to to the document direct on first launch. That is just the way it is.

like image 192
rckoenes Avatar answered Oct 02 '22 10:10

rckoenes