我有一个我提交给Apple Mac App Store的Qt应用程序。写入〜/ Library / Preferences / com.mycompany.myapp
已被拒绝这是我收到的消息:
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).
如何解决这个问题?
答案 0 :(得分:5)
我认为您正在使用QSettings保存应用程序设置。您的代码可能如下所示:
QApplication app;
app.setOrganizationDomain("nourayn.com");
app.setApplicationName("AlMosaly");
QSettings settings; // this creates a .plist file under ~/Library/Preferences
// which is non-MacAppStore-friendly
相反,您可以使用明确指定的文件名创建QSettings:
app.setOrganizationDomain("nourayn.com");
app.setApplicationName("AlMosaly");
QSettings settings(yourAppDataFolder+"/settings.plist", QSettings::NativeFormat);
// this writes to the file you specified
如果您在应用中的多个位置使用QSettings,这样做可能会让事情变得轻松一些:
// in main.cpp
app.setProperty("SettingsFileName", yourAppDataFolder+"/settings.plist");
// in someotherfile.cpp
QString settingsFileName = qApp->property("SettingsFileName").toString();
QSettings settings(settingsFileName, QSettings::NativeFormat);
此外,如果你在〜/ Library /(存储Qt全局设置)中有一个com.trolltech.plist文件,你可能需要转到Qt 4.8.1。更多信息: http://qt-project.org/doc/qt-4.8/qsettings.html#changing-the-location-of-global-qt-settings-on-mac-os-x
答案 1 :(得分:1)
Apple开发人员文档解释了使用文件系统时允许的内容。您可以选择使用API调用来处理它,否则您的位置和命名数量有限。 Read in detail here
Your application may write to the following directories:
~/Library/Application Support/<app-identifier>
~/Library/<app-identifier>
~/Library/Caches/<app-identifier>
如果您使用的是QSettings,它将选择存储prefs的系统位置,那么您可能需要更改该方法以更直接地控制目标。
对于QSettings,请阅读有关如何根据平台/范围更改首选位置路径的文档:http://qt-project.org/doc/qt-4.8/qsettings.html#setPath
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope,
"/path/to/location");