Save location with iOS

Hello everyone,

I’ve successfully compiled and submitted apps with the newest iOS version of openFrameworks (so everything is still working well).
However, I noticed that the data folder is synonymous with the /private/var/containers/Bundle/Application/6BDDC0F8-9C7A-47C0-B608-62D7F35C581B/myopenframeworks.app path instead of App.app/Documents.
On the Simulator file saving works but when you submit it on the App Store you get issues since you can’t store files on the Library path, only to the Documents path. So far I haven’t managed to store the files to the Documents folder successfully.

I like to twiddle around with it more but since this is an issue with the App Store it takes a day of submission each time just to check if it’s working. So this is why I wanted to ask, did any of you encounter this problem and solved it?

Best,
Kevin

Ok I found the answer.
So the default data/ path is written to /private/var/containers/Bundle/Application/6BDDC0F8-9C7A-47C0-B608-62D7F35C581B/ which you cannot modify within an application.

To get the modifiable Documents folder you can do the following:

char *home = getenv("HOME");
string subdir = "/Library/Documents/";
    
String locationOfSavesLevels = string(home) + subdir;

I had two folders: data/saves and data/levels.
So at the end I simply copied these files on startup and from then on only referenced them from the Documents location.

void ofApp::setup(){	    
    //for ios use the Documents directory:
    char *home = getenv("HOME");
    string subdir = "/Library/Documents/";
    
    String locationOfSavesLevels = string(home) + subdir;
    ofDirectory iosdocuments(locationOfSavesLevels);
    ofDirectory saves("saves"); //location of /data/saves
    ofDirectory lvls("levels"); //location of /data/levels
    if(!iosdocuments.exists()) {
        iosdocuments.createDirectory("");
        saves.copyTo(iosdocuments.getAbsolutePath()+"/saves");
        lvls.copyTo(iosdocuments.getAbsolutePath()+"/levels");
    }

Cheers!