2
我正在開發一個Qt 5.6的跨平臺應用程序。當應用程序啓動時,它創建的應用程序目錄中的一個文件:Permisison與MAC OS上的Qt應用問題謝爾
QFile file;
// /MyApp.app/Contents/MacOS
file.setFileName(QApplication::applicationDirPath() + QString("/file.csv");
file.open(QIODevice::ReadWrite | QIODevice::Truncate);
...
file.close();
這適用於舊的OS X版本完全正常,但由於塞拉利昂,這個文件是不是再生(僅當該應用程序從互聯網上下載)。請注意,我不會在MAC存儲上發佈我的應用程序,我只是使用.dmg文件。
這裏是我做了一些測試:
- 編譯應用程序並啓動塞拉利昂=>OK
- 編譯應用程序,創建一個.dmg並啓動塞拉利昂=>OK
- 編譯應用程序,創建一個.dmg(我上傳),下載和塞拉利昂啓動應用程序=>失敗
我認爲問題與權限訪問有關。這種單一的命令行解決我的問題,但我當然不能給這個解決方案爲我的用戶:
sudo spctl --master-disable
這是我籤我的應用程序:
# Signing application
codesign --force --deep --sign "Developer ID Application: *** ***" /MyPath/MyApp.app
# Validating signature
spctl --assess --verbose /MyPath/MyApp.app
這裏是我的信息。由Qt生成的plist文件:
<?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>
我對MAC簽名工具不是很熟悉,所以任何幫助都將不勝感激。謝謝。
你是完全以正確的。不幸的是,我沒有這個特定文件的選擇。 – Sierra
@Sierra我不知道從個人的經驗,但是我可能會嘗試GUI sudo來運行你需要的命令,然後用戶會被提示輸入密碼並繼續進行:http://www.performantdesign。 com/2009/10/26/cocoasudo -a-graphical-cocoa-based-alternative-to-sudo/ –
是的,它會是完美的,但'AuthorizationExecuteWithPrivileges'似乎已被棄用,因爲OS_X 10.7 – Sierra