Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

petron

macrumors member
Original poster
May 22, 2009
95
0
Malmo, Sweden
Hi,
Until now I have used tar.gz combination for distribution of software.
But the use of .dmg file is a better and more convinient way for the Mac OS X world in order to distribute a software.

My question is how I can control that some files placed into the new created disk image can be installed in a specific folder when running the "instalation" by accessing the .dmg file.

I would like to place some application support files in a specific folder.

For instance I want to place file1.db into:

~/Library/Application Support/My_Software/file1.db

I appreciate the help.
/petron
 
You can't. Although you can't really do that with a tar.gz structure either. You have two options: put an Installer package in the dmg or include the file in your apps resources and if it's not where you expect when you run copy it there.
 
Hi robbieduncan,
Thanks for the info. It at least explains why I could not make it.

Installer Package - Never done it yet, may be it is time to do it now.

Do you mean, I Just create a small App that creates the folder and copies over the resource file there ?

/petron
 
Do you mean, I Just create a small App that creates the folder and copies over the resource file there ?

No: either create a real Apple Installer package (rolling your own doesn't work with management tools like ARD). If you don't want to do that then the main application you are distributing should just copy the file from it's own Resources folder to wherever you need it.

In general if you need this file for you application to run then it should not be in Application Support: as per the documentation "A support file is any type of file that supports the application but is not required for the application to run. Document templates and sample files are simple examples of support files." If you absolutely require this file and it's read-only then it belongs within the application itself. If it's read/write then somewhere in ~/Library/ (but not Application Support by the book, although many would say it's OK).
 
Hi Robbieduncan,
Thanks for more explanations.

I will probably implement functionality in my App to create the folder and to move the file I need there. It should not be a big problem.

Regarding the placement/location of the folder I am not sure what to choose. I am a bit confused and seems that I need to read a bit on this subject.

Generally my App has no problem at all to start up without that extra file. When starting without it I currently show an Alert informing that the file is missing. There is only some extra functionality that will be blocked. At the same time I need a location folder for user entered information stored in an database file. The idea was to put it in the same location. Both files can be extracted and transferred to other users in order to share the information. It would be convenient.

Personally I do not have strong feelings where to put it.
I would be either:
~/Library/Application Support/myFolder
or
~/Library/myFolder

Do you have any comments ?

/petron
 
If it's not required then I'd say ~/Library/Application Support/myFolder where myFolder should be the name of your application. If the file could be shared between users you should probably also check /Library/Application Support/myFolder (but if it has per-user data then don't bother).
 
Hi Robbieduncan,

A Note:
The database files do not need to be shared but can be exchanged between different users on different computers, not necessary on the same computer. I will stay then at ~/

I made the changes and it works nearly nicely. I have got a small exception.

As long as I put the application into the /Applications folder all works fine, but the user can even start/place the application from other places.

How can I get the path to the
/<NotApplication>/MyApp.app/Contents/Resources

Is there a method to get that path over ?

Thank you in advance
/petron
 
You should never assume that your application is in /Applications.

Thats for sure. For instance, I place third party apps in a subfolder of the Applications folder. Well, when they, or other application does make that silly assumption. Handbrake assumes VLC is in the the Applications folder.
 
Thanks again...

I got it now and it works.

Code:
  NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
  NSString *srcPath = [myBundle pathForResource:@"cfgTemp" ofType:@"xml"];


/petron
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.