从源代码为macOS 10.12.6构建qt 5.10.0时出错“qwebview_darwin.mm:261:24”

时间:2017-12-18 20:53:13

标签: macos-sierra qt5.10

我想使用版本10.12.6(Sierra)从我的macOS源代码构建新的Qt5.10.0版本。

这些错误发生在构建过程结束时:

qwebview_darwin.mm:261:24: error:
'loadFileURL:allowingReadAccessToURL:' is only available on macOS 10.11
or newer
[-Werror,-Wunguarded-availability]
[wkWebView loadFileURL:url.toNSURL()
                   ^~~~~~~~~~~~~~~~~~~~~~~~~

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebView.h:102:1: 
note: 
'loadFileURL:allowingReadAccessToURL:' has been explicitly marked
partial here
- (nullable WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL API_AVAILAB...
^
qwebview_darwin.mm:261:24: note: enclose
'loadFileURL:allowingReadAccessToURL:' in an @available check to
silence this warning

[wkWebView loadFileURL:url.toNSURL()


                   ^~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated.
make[4]: *** [.obj/debug/qwebview_darwin.o] Error 1
make[3]: *** [debug-install] Error 2
make[2]: *** [sub-webview-install_subtargets] Error 2
make[1]: *** [sub-src-install_subtargets] Error 2
make: *** [module-qtwebview-install_subtargets] Error 2

也许你有一些技巧来处理这个错误。 你知道吗,我要做什么? 以及如何绕过这些错误?

2 个答案:

答案 0 :(得分:1)

根据this report on the Qt bug tracker,这似乎在5.10.1(以及5.9.4)中得到修复,因此拉动新版本可以解决您和我的问题而无需编辑Qt源

我现在可以确认5.10.1中的代码现在由

保护
if (__builtin_available(macOS 10.11, iOS 9, *)) {

答案 1 :(得分:0)

loadFileURL支票中附上@available的来电,如下所示

if (@available(macOS 10.11, *)) {
    [wkWebView loadFileURL:url.toNSURL() allowingReadAccessToURL:QUrl(url.toString(QUrl::RemoveFilename)).toNSURL()];
}