Accessing the resources folder (pdf template)

I have a pdf template that I’m populating using the MBS DynaPDF classes. Right now I just let it hang out next to the application but ideally it’d be nice to stick it in the resources folder. As I was poking around for an answer I noticed the resource fork class is deprecated. Dragging the pdf to the IDE does give me way to access it (and presumably it’ll end up in the resources folder when I compile) but that access is as a string. And I’m not finding an MBS class that imports using a string. It appears to want a folderitem.

What’s the best way of implementing this?

Implementations vary, and I can’t say if my way is the “best,” but it works.

I have an app where I embed a VirtualVolume into it that contains a bunch of resources for my app (including PDF help files). During initial launch the app checks to see if the files already exist. If not, it expands the VV and copies the items from it to the target folder.

The trick is I convert the VV file to a string using b64 encoding and then that file is dragged into my project. Thus the file is automatically included with builds of the app. I have a method that takes that string, undoes the b64 so it’s binary again, and writes it as a temporary binary file which I can then read as a VV file. (The file’s deleted once I’ve finished copying items out of it.) Sounds complex, but it’s very fast.

Now that Xojo has IDE scripting, I could use a script to copy the files into the app build directly instead, which is another approach you could take and might be easier/better.

For Mac, you can stick your folder in the Resources of the App Package. This is perfectly acceptable under OSX. right click on the app and choose “Show Package Contents”. Open the Resource folder and copy your Folder to that location. It is then accessed within your app using: app.ExecutableFile.Parent.Parent.Child(“Resources”).Child(“My Folder”)

That’s what I was looking for. I wrongly figured it’d be in the specialfolder.

For anyone finding this thread later let me offer a quick workflow tip. Drag the item you want to locate in the resources folder into the IDE. That will save you the trouble to opening up the package each time, an added benefit is the name of the file will autocomplete. This only works on the Mac. On Windows the item will not be put in the libs folder, instead it is complied into the executable.