Reputation: 601
I’m developing a cross platform application with Qt 5.6. When the application starts, it creates a single file on the app directory:
QFile file;
// /MyApp.app/Contents/MacOS
file.setFileName(QApplication::applicationDirPath() + QString("/file.csv");
file.open(QIODevice::ReadWrite | QIODevice::Truncate);
...
file.close();
This works perfectly fine with old OS X versions, but since Sierra, this file is not regenerated (only if the app is downloaded from internet). Note that I do not publish my app on the MAC store, I simply use a .dmg file.
Here are few tests that I’ve done:
I think the problem is linked to permissions access. This single command line solve my problem, but of course I can’t give that solution for my users:
sudo spctl --master-disable
This is how I sign my application:
# Signing application
codesign --force --deep --sign "Developer ID Application: *** ***" /MyPath/MyApp.app
# Validating signature
spctl --assess --verbose /MyPath/MyApp.app
And here is my info.plist file, generated by Qt:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIconFile</key>
<string>mac_app_icon.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleExecutable</key>
<string>MyApp</string>
<key>CFBundleIdentifier</key>
<string>com.company.myapp</string>
<key>NOTE</key>
<string>This file was generated by Qt/QMake.</string>
<key>LSUIElement</key>
<true/>
</dict>
</plist>
I’m not very familiar with MAC signing tool, so any help would be highly appreciated. Thank you.
Upvotes: 2
Views: 1248
Reputation: 12317
Probably not the answer you are looking for, however it has been best practice to store data away from executables for some time. Writing at the location of QApplication::applicationDirPath()
is not advisable.
Ideally you should be storing runtime information in standard locations:
http://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum
QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first();
Upvotes: 4