File read/write on mac -- permissions needed?

Hi all,

Here is a minimal example of a function which loads an XML file and updates the contents into a text editor.

   XmlDocument myDocument (File::getCurrentWorkingDirectory().getChildFile ("myFile.xml"));
    
    if (auto mainElement = myDocument.getDocumentElement())
    {
            auto contents = mainElement->getStringAttribute("contents");
            
            // update box
            textEditor->setText(contents);
        }
    }

If I run this through Xcode everything works great. File is loaded. However, if I double click on the .app (in the “release” folder), it dosen’t work. Oh no!

I’m guessing this is to do with Apple’s permissions (I am on Catalina 10.15.6), but I’m very inexperienced with this sort of thing. Do I need a developer ID or something like this? Is this something to do with sandboxing? I only want to run the app for personal use and am not looking to distribute, so surely there is a simpler answer? No?

Thanks in advance for the help!

IIRC the result for File::getCurrentWorkingDirectory() is not the same executed from Xcode.

1 Like

Aha! Nail on the head. Should’ve thought of checking these :person_facepalming: . Thanks!

1 Like