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