iOS : include audio files in an app, in its sandbox directory

What would be the way to include some soundfiles in the project resources so they can be found, once the app launched, in the sandbox Documents folder by the FileBrowserComponent ?

This is something I could finally do, by getting the proper info.
When we add a sound in the XCode resources, it is put by default at the same level as the executable file :


The path for my audio file created with the function below :
File audioFile = File::getSpecialLocation (File::currentExecutableFile).getChildFile (String(“iambe.wav”));

gives this as a full path name :

So, the file browser can find the audio file and play it.
( Of course, up to me to put the file in a more appropriate folder )

This has been helpful for me when trying to figure this out:

  1. The iOS closed File System (aka sandbox)

  2. And this thread helped me get started:
    Sandboxed ios app "Documents" folder location?

You can ofcourse set a FileBrowser to the right path and use its method for dragging/clicking to handle the files.

Yes, I went through these steps.
However, when I try to bypass the fileChooser, creating the file in JUCE according to the place where it is supposed to reside, and then ask if it exists, it says NO. Despite that I can find it if I open the path given by getFullPathName, when run by the Simulator :

    audioFile = File::getSpecialLocation (File::currentExecutableFile).getChildFile (String("iambe.wav"));
    String path = audioFile.getFullPathName();
    std::cout<<"path = "<<path<<"exists : "<<audioFile.exists()<< "\n";

So I tried a basic text loading example. I found that I could reach the enclosed file by invocating the following path : (compiled for OSX)
myFile = File::getSpecialLocation (File::currentApplicationFile).getChildFile (String(“Contents/Resources/truc.txt”));
… BUT for iOS I still can not get the file :
myFile = File::getSpecialLocation (File::currentApplicationFile).getChildFile (String(“truc.txt”));

I saw also the following post which is interesting as well, but not yet the answer :

This isn’t an answer directly, but this really helped me figure out where those files that show up as Xcode Resources actually appear on iOS:

    Array<File> results;
    File::getSpecialLocation( File::SpecialLocationType::currentApplicationFile).findChildFiles(results, File::findFilesAndDirectories, true);
    for( auto& result : results )
        DBG( "result: " << result.getFullPathName() );

sure enough, it gave me everything I needed to know about where the Xcode Resources were actually located on iOS compared to OS X!