3

I am trying to enable sandboxing on an application I am working. Although the application is heavily on a file system, for creating and saving and loading user files, It doesn't need the files to be located outside of the App container. But by enabling Sandboxing, I cannot write files in app anymore.

Is there anyway to achieve that?

void DeterminePaths(const string &a_arg0)
{
    string  s;
    FSRef   ref_num;
    char    str_path[1024];
    OSErr   e = noErr;

    e = FSFindFolder(kOnSystemDisk, kCurrentUserFolderType, false, &ref_num);
    e = FSRefMakePath(&ref_num, (UInt8*)str_path, 1024);
    s = string(str_path);

//Then I add on 's' the local directories for example s + "/silly_things"
}

<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
</dict>
  • could you post your entitlements file? And the code you use to get the container directory? – mahal tertin Feb 24 '17 at 09:17
  • Thanks in advance, I hope this helps! –  Feb 24 '17 at 13:50
  • the container directory is available thru NSFileManager. Sandbox doesn't really play well with FSRef, try to use NSURL. – mahal tertin May 29 '17 at 18:23
  • @mahaltertin Thanks for your comment, I actually went an other way, the data can be saved in a generated Application folder in the Library. –  May 31 '17 at 06:46

0 Answers0