Important: Please read the Qt Code of Conduct -

macdeployqt strips resources from deployed binary

  • Hey all,

    I'm working on a project which needs to deploy to the macos and while everything compiles fine (through out cmake build system) and the binary runs fine on my development machine; when I run the macdeployqt binary on the app bundle the resources seem to get stripped out. I've played with all the options on macdeployqt, but nothing changes this behavior. Does anyone have any advice? The binary works otherwise, but all of our branding images are gone.

  • Lifetime Qt Champion


    What version of Qt ?
    What version of Xcode ?
    What version of macOS ?
    Can you provide a minimal compilable example that shows that behaviour ?

  • Qt 5.10
    Using clang directly via cmake which has version string clang-900.0.39.2
    Macos 10.13.3

    Not sure if I can provide a a minimal example, as the images do get compiled into the binary and work fine. Only the deploy step messes up.

  • Lifetime Qt Champion

    That's the goal: build the same application as you and try to trigger the bug with macdeployqt.

  • Moderators

    @DJ-Ogurt just to make sure, you actually modified your *.pro file to add extra sources to the app-bundle, using QMAKE_BUNDLE_DATA? As far as I know macdeployqt does not copy automatically non Qt-Related (ressource files, frameworks etc) files to make the bundle Executable. The Windows tool doesn't either.

    wiki link
    docs link

  • @J-Hilk I'm not using a *.pro file. I suppose that could be the issue if the deploy program looks for that. Should the project file be in the same directory as the binary or as the app bundle?

  • Moderators

    @DJ-Ogurt you missunderstood me.

    The macdeployqt-tool does not need a .pro file. It will go through your qt installation and fetch all (most of the time) dependencies of application and copy them to the appropriate location inside your .app file.
    Somtimes you'll have to specify a path, for example if you use qml you'll have to tell the tool where to look for those, or other options.

    If your application needs additional files that are not part of the binary - for example pixtures in your case, you will have to

    • a: copy those by hand to the correct place
    • b: use the QMAKE_BUNDLE_DATA inside your Qt-Project file to tell qmake(I believe) to copy the needed files to the correct place, when creating the binary

  • Ok. So I don't believe I'm using any qml. I do have a qrc file which is included with my cmakelists.txt with


    Images are used in the ui_headers with lines like

    <string notr="true">background-image: url(:/images/background.svg)

    the folder images is a sub directory in resources.

    I'm fine with coping by hand, but I'm not sure where in the app bundle the images should end up.

  • Moderators

    @DJ-Ogurt ah ok,
    when all your images are part of the qrc file than they should be part of the binary, and you shouldn't have any more work with it. So I'm kind of out of ideas .

    One last one, all those images that are not displayed/missing, do they happen to be svg files?

    Maybe QtSvg.framework was not copied correctly? You should check that.

  • @J-Hilk
    That's exactly what I thought. They are svg images and it seems that QtSvg.framework is in there. Here's a tree of the svg framework sub dir in Contents/Frameworks/QtSvg.framework/
    ├── QtSvg -> Versions/Current/QtSvg
    ├── Resources -> Versions/Current/Resources
    └── Versions
        ├── 5
        │   ├── QtSvg
        │   └── Resources
        │       └── Info.plist
        └── Current -> 5
    5 directories, 3 files

    This tree view is after the mac deploy has been run on the app bundle.

  • Just ran into this issue myself. Did you end up finding a resolution?

  • @Richicoder
    All frameworks are being copied correctly, the problem is with the svg plugin - you have to copy it later manually. On my MacBook I had to use those commands after using macdeployqt:

    cd <bundle path>/Contents/PlugIns/imageformats
    cp /usr/local/Cellar/qt/5.11.1/plugins/imageformats/libqsvg.dylib .
    install_name_tool -change /usr/local/Cellar/qt/5.11.1/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui libqsvg.dylib
    install_name_tool -change /usr/local/Cellar/qt/5.11.1/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets libqsvg.dylib
    install_name_tool -change /usr/local/Cellar/qt/5.11.1/lib/QtSvg.framework/Versions/5/QtSvg @executable_path/../Frameworks/QtSvg.framework/Versions/5/QtSvg libqsvg.dylib
    install_name_tool -change /usr/local/Cellar/qt/5.11.1/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore libqsvg.dylib

  • Related bug report: QTBUG-55199

Log in to reply