macdeployqt does not copy the QtWebView plugin

201 views Asked by At

I could not find a way to inform macdeployqt that I need QT_ROOT/qml/QtWebView/libdeclarative_webview.dylib to be copied into the app bundle. This is needed to use native QtWebView in QML (configured with QT_WEBVIEW_PLUGIN=native). Is there a way to avoid manual copying and rely on macdeployqt instead?

Note that the library QT_ROOT/plugins/webview/libqtwebview_darwin.dylib is correctly recognized and included in the bundle.

The project is built with cmake, Qt version is 5.15.2. Essential steps are shown below.

find_package(Qt5 REQUIRED COMPONENTS ... WebView)

target_link_libraries(${binary} ... Qt5::WebView)

execute_process(
    COMMAND ${qt_root}/bin/macdeployqt
    ${CMAKE_INSTALL_PREFIX}/bin/my_app_bundle.app
    -qmldir=${qt_root}/qml
)
1

There are 1 answers

0
Volodymyr Lashko On BEST ANSWER

The issue was in misusing qmldir and qmlimport. Correct invocation is

execute_process(
    COMMAND ${qt_root}/bin/macdeployqt
    ${CMAKE_INSTALL_PREFIX}/bin/my_app_bundle.app
    -qmldir=${CMAKE_CURRENT_SOURCE_DIR}/quick_ui
    -qmlimport=${qt_root}/qml
)