Add file to .app package?


#1

Hi,

I am currently compiling my stand-alone application for OSX.
And I want to put a PDF file into the application. It is used for displaying the help of the application.

As I have seen, in OSX the whole application is created as a .app file, which actually is a package with an internal file structure. I want to put a PDF file under
/Contents/MacOS
I would like to do that from the Projucer. Is that possible? I assume I could do it in Xcode. But it would be better, I think, if I can do it in the Projucer.


#2

Add the file in the projucer, then when you click the group in the file drop down menu you will see some check boxes. Unmark “binary resource” and check “Xcode Resource.”

Then when you need to access the file in your code, all you need to do is this:

File myFile = File(File::getSpecialLocation(File::currentApplicationFile).getFullPathName() + "/Contents/Resources/myFile.pdf");

#3

Thanks!
Did not know about that. Very convenient :slight_smile:


#4

If you want to add a folder full of files, you can also add it using the projucer like this (assuming the folder as sibling to the jucer file)