Ahmed Said
Ahmed Said

Reputation: 1315

Qt Mac App Store application rejected for file system requitements

I have a Qt app I submitted to Apple Mac App Store. It's been rejected for writing to ˜/Library/Preferences/com.mycompany.myapp

here's the message I received:

2.30

The application accesses the following location(s):

'~/Library/Preferences/com.nourayn.AlMosaly.plist'

The application may be 

* creating files
* writing files
* opening files for Read/Write access (instead of Read-Only access)

in the above location(s).

How to fix this?

Upvotes: 2

Views: 1862

Answers (2)

roop
roop

Reputation: 1301

I presume you're saving your application settings using QSettings. Your code probably looks like this:

QApplication app;
app.setOrganizationDomain("nourayn.com");
app.setApplicationName("AlMosaly");
QSettings settings; // this creates a .plist file under ~/Library/Preferences
                    // which is non-MacAppStore-friendly

Instead, you can create your QSettings with an explicitly specified filename:

app.setOrganizationDomain("nourayn.com");
app.setApplicationName("AlMosaly");
QSettings settings(yourAppDataFolder+"/settings.plist", QSettings::NativeFormat);
                    // this writes to the file you specified

If you use QSettings at multiple places in your app, doing this might ease things a little:

// in main.cpp
app.setProperty("SettingsFileName", yourAppDataFolder+"/settings.plist");

// in someotherfile.cpp
QString settingsFileName = qApp->property("SettingsFileName").toString();
QSettings settings(settingsFileName, QSettings::NativeFormat);

Moreover, if you have a com.trolltech.plist file in ~/Library/ (which stores Qt global settings), you may need to move to Qt 4.8.1. More info here: http://qt-project.org/doc/qt-4.8/qsettings.html#changing-the-location-of-global-qt-settings-on-mac-os-x

Upvotes: 5

jdi
jdi

Reputation: 92637

The apple developer docs explain what is allowed when working with the filesystem. You are given the option of using API calls to handle it for you, otherwise you have a limited number of locations and naming. Read in detail here

Your application may write to the following directories:
~/Library/Application Support/<app-identifier>
~/Library/<app-identifier>
~/Library/Caches/<app-identifier>

If you are using a QSettings, which will choose the system location to store prefs, then you might need to change that approach to more directly control the destination.

For QSettings, read the docs about how to change your path to a preferred location on a platform/scope basis: http://qt-project.org/doc/qt-4.8/qsettings.html#setPath

QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, 
                    "/path/to/location");

Upvotes: 1

Related Questions