Important: Please read the Qt Code of Conduct -

Can't create/write files in iOS filesystem

  • Hi!
    I have found some posts related to this problem, but I couldn't find a solution yet. This is my situation:

        QString id = "project_01";
        QString dir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0];
        dir += "/" + id;
        if (!QDir(dir).exists()) {
            if (!QDir().mkdir(dir)) {
                qDebug() << "Fatal error: Insufficient premissions to create directory -> " << dir;

    I got this message from console:

    Fatal error: Insufficient permissions to create directory ->  "/private/var/mobile/Containers/Data/Application/2887FBCE-B1C0-421B-A880-59F97B9W1F8C/project_01"

    Trying to fix the problem, I used these other options with no luck:

    QString dir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
    QString dir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
    QString dir = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);

    I am using Qt 5.8 and testing with an iPad Air and an iPad 2. Same result. Any suggestion?

    PS: I wonder if it isn't necessary to add some +write permission into the Info.plist file of the app. In Android this is required to create files and directories but I have no experience on iOS.

  • Solved using this path:

        QString dir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];

  • Qt Champions 2016

    @xtingray I'm also using this location to create/write files:


    works on Android and iOS

    HomeLocation works on Android but not iOS

  • Your suggestion worked pretty well in Windows and Android. For some reason, it failed in my iPad 2. Anyway thanks! :)

  • Qt Champions 2016

    @xtingray just verified:

    installed app new on iPad Mini 2, so all my directories will be created new, then data downloaded from REST and stored at AppDataLocation.
    all works well

    AllTourse HTTP STATUS:  200  Bytes:  92951
    Data Bytes written:  92951  to Tours file:  "/var/mobile/Containers/Data/Application/E08AB1F2-C3A6-419E-A413-3A4739B0AFE9/Library/Application Support/ProfSYS/data/profsys/tours/allTours.json"

    Qt 5.8 QtQuickControls2 App
    iOS 10.1
    then updated to iOS 10.2.1, deleted app did again

    all is working as expected

Log in to reply