QtWebBrowser macOS 签名问题

QtWebBrowser macOS Signing Issue

我最近 运行 遇到一个与 macOS 上的 QtWebBrowser 相关的奇怪问题。 QtWebEngine 控件似乎没有在我的开发机器之外加载。我已经追踪到签名。如果我构建应用程序但不对其进行签名,我可以 运行 在另一台机器上正常运行。一旦我签署了应用程序,QtWebEngine 控件就会停止在其他机器上加载。当我回去测试旧版本并且它做了同样的事情时,它变得更加奇怪。这是我之前构建和测试过的版本,绝对可以正常工作。我相当确定我正在测试的计算机从那时起就没有更新过。

一些看起来像是线索的东西是现在出现的警告。不记得以前看过

2019-04-28 22:11:30.247507-0700 QtWebEngineProcess[30607:140529] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x106f08560> (Domain: com.apple.universalaccess, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access

这是我用来签署应用程序的命令。

sudo codesign --deep --force --verify --verbose --sign "Developer ID Application: ***" --options runtime Output/MyApp.app

经过反复试验,我找到了解决此问题的方法。我相当肯定,任何试图使用 QtWebEngine 公证 macOS 应用程序的人都需要这样做。希望这会在将来为某人节省一些时间。

我的解决方案是使用 com.apple.security.cs.disable-executable-page-protection 异常对 QtWebEngineProcess 进行签名。这是过程。

使用以下命令签署主应用程序

sudo codesign --deep --force --verify --verbose --sign "Developer ID Application: ***" --options runtime MyApp.app

为 QtWebEngineProcess 创建授权文件

<?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>com.apple.security.cs.disable-executable-page-protection</key>
    <true/>
</dict>
</plist>

使用以下命令签署 QtWebEngineProcess

sudo codesign --force --verify --verbose --sign "Developer ID Application: ***" --entitlements QtWebEngineProcess.entitlements --options runtime MyApp.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess

使用以下命令签署主要可执行文件

sudo codesign --force --verify --verbose --sign "Developer ID Application: ***" --options runtime Output/MyApp.app/Contents/MacOS/MyApp

完成这些步骤后,我能够成功地对申请进行公证。