Adding binary files in packages for multiple platforms


#1

I am writing an app that must work on various platforms (iOS, MacOS, Win and later Android). This app will have a list of files that it will regularly read from. This list must be dynamic, ie more files can be added (from a web site or any other location) or even deleted. I don"t want to use Binary::Data scheme for this particular purpose. So here is my question:

What is the best location to store those files ? This location must be:

- included in the package for iOS and Mac, and in the install program for Win

- accessible from a Juce-enabled app (eg using getSpecialLocation or some other method from Juce modules)

- defined at compile/build time using XCode for iOS and MacOSX, and some automatic means for Win and Android (for instance I tried to define the file location using the Build Phase page in XCode but the actual picked location was different depending on the target (iOS or MacOS))

- and if possible visible and accessible by the final user using standard browsing tools.

In other words how can I define this location so that I can use the same code to access the files on all platforms, the app being installed from a package by the user ?

Thanks in advance for any suggestion...


#2

Any clue, someone ?

Or is it just a silly question ?

In case I was not clear here is an example:

I want to include several mp3 files in my app package, and also allow the user to add more or delete some. I would like (if possible) the same code to run on iOS, Mac and Win (and Android later). Where should I put them ("Bundle Resources" ?) under XCode and which parameter ("getSpecialLocation()" ?) should I use to retrieve and play them in my app ?

Or do I have to manually check where the files are located for every platform and use #if directives for each and every platform ?

Thanks !


#3

It's not a silly question, but it's also not easy to answer since the answer is different on all the different platforms. E.g. on OSX you can put files in the app bundle, but on Windows you'd need to include them in your installer to be put into an appropriate location.


#4

Well I guess what you mean is that we *do* have to use separate codes for each platform. I was hoping for some magic code you would have embedded somewhere to do the trick. Like for instance find a way on each IDE to say "put the files in the same folder as in the app itself (or a subfolder from there)" and then "use this SpecialLocation to retrieve them" with the same code.


#5

There's certainly magic code in the introjucer that will embed any files as binary data directly in your app, but not as files on the target system.

A trick I sometimes use is that if you have some small default files, you can embed them as binary data and then when the program is first run, it can write them into some shared folder appropriately for the platform.

But certainly if you can use embedded binary data and not need to have physical files, then that's a much easier and more robust approach.


#6

Thank you for taking the time to answer.

I agree that your Binary Data scheme works great and I already use it but,  as said in my initial post, I don't want to use Binary data here because I also want to dynamically add and delete files in the same folder, and have them accessible by standard file explorers.

I'll figure out something.

Thanks again.

A.


#7

I know this is 3 years later, but I’m doing the exact same thing.

  • I use BinaryBuilder to put the files in the App Binary
  • On first run, write those files to the shared folder
  • Allow the user to also add files to that shared folder