SVG icons do not show up on the deployed app



  • So I am working on an application that I want to deploy on MacOS.
    I have compiled my code and I can run the app from QtCreator.
    I tried to deploy both manually and by using the macdeployqt.
    Everything gets copied and I can run the app.
    The problem is when I just run the app from the finder all my icons with SVG are not visible.
    But if I run the app from Terminal from inside the bundle like:

    cd ~/Desktop/Myapp.app/Contents
    ./MacOs/Myapp 
    

    Then it runs and the SVG icons are there.
    I have tried almost everything but I can't figure out what is the problem.
    I am using Qt 5.7.1 and running on MacOS 10.12.3


  • Moderators

    You are talking about SVG icons inside your application (in the gui), right? Do you pack them into your binary using QRC or use relative paths?



  • I am using QRC. And yes I am talking about the icons in the Gui.


  • Moderators

    Hm it has to work then... unless there is some problem loading SVG module - try saving logs to some file and inspect it.

    Or you open QRC via relative path and that fails.



  • did you deploy the imageformats plugin qsvg.dll?



  • If the path was wrong then how come the icons are there when I open the app from command line as I mentioned in my initial post but that also only works if I call it directly from my Contents directory.
    I also deployed the imageformats plugin but with libqsvg.dylib not qsvg.dll since I am deploying on the MacOS.



  • I also tried DYLD_PRINT_LIBRARIES=1 and QT_DEBUG_PLUGINS=1 to see the libs and plugins that are getting used. But the SVG plugin gets called only when I run the app from terminal in the Contents directory.


  • Moderators

    @hhoushiar said in SVG icons do not show up on the deployed app:

    If the path was wrong then how come the icons are there when I open the app from command line as I mentioned in my initial post but that also only works if I call it directly from my Contents directory.

    Current dir is different when you run from Contents that when you run the app from Finder. This can be mitigated by using QCoreApplication::applicationDirPath() to "anchor" your relative paths.

    As said though, if you use QRC the standard way (compiled into app binary), paths cannot be a problem.



  • One more thing when it fails to show the icons I get errors like:
    QML Image: Error decoding: something.svg Unsupported image format
    So I think the problem is that it cannot find the plugin.
    But I don't know that else I have to add since the plugin is in the correct directory.
    Should I modify something?


  • Moderators

    @hhoushiar Please read what @VRonin asked above



  • @jsulm Thanks for your reply but I have already deployed the libqsvg.dylib in PlugIns/imageformats.
    I am also using sql plugins and they are running without a problem. The problem is only with the SVG.
    I have tried almost all the solutions that I could find online but unfortunately nothing has worked for me.


  • Moderators

    @hhoushiar can you execute "ldd libqsvg.dylib" on the target machine?



  • @jsulm So the equivalent to "ldd" on MacOS is "otool -L" if I am not wrong.
    and I execute this for libqsvg.dylib in my plugins and here is the output:

    libqsvg.dylib:
    	libqsvg.dylib (compatibility version 0.0.0, current version 0.0.0)
    	@rpath/QtSvg.framework/Versions/5/QtSvg (compatibility version 5.7.0, current version 5.7.1)
    	@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.7.0, current version 5.7.1)
    	@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.7.0, current version 5.7.1)
    	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.7.0, current version 5.7.1)
    	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
    

    I also have the QtSvg, QtWidgets, QtGui and QtCore frameworks in Frameworks directory of my app bundle.


  • Moderators

    @hhoushiar said in SVG icons do not show up on the deployed app:

    I have already deployed the libqsvg.dylib in PlugIns/imageformats

    I don't know how things are done on macOS, but for Windows and Linux the path is <app>/imageformats/, not <app>/PlugIns/imageformats

    Does the new location help?



  • @JKSH said in SVG icons do not show up on the deployed app:

    I don't know how things are done on macOS, but for Windows and Linux the path is <app>/imageformats/, not <app>/PlugIns/imageformats

    Thanks for the reply but unfortunately that does not help. Under MacOS the app bundle structure should contain Frameworks to put all the libs, Plugins to put all the plugins and Resources to put the qml stuff.
    I followed this based on the Qt documentation "Qt for macOS - Deployment". I am using QtSql.frmawork and sqldrivers plugins the same way and they work just fine. The problem is only with imageformats and SVG.



  • Does anyone have any other idea?
    I really need to be able to deploy the app soon.
    I really appreciate any help.



  • There is a separate plugin for SVG icons, on windows it's iconengines/qsvgicons.dll did you deploy that one?



  • @VRonin Thanks for your reply.
    Yeah I have that as well.
    Actually a few days ago I deployed the app under windows and I thought the MacOS should be easier and that was a big mistake.



  • Still not working.
    I don't know what is the difference between the SVG plugin and for example the platform or sql plugins.
    I tried to change the qt.conf file that did not help.
    Funny thing is if I don't copy the Qt stuff in the app bundle and let it use the frameworks and plugins directly from Qt installed directory it works but when I copy them into my app bundle it does not work.
    Is there a way to see what plugins the application tries to open and where it is looking for them?
    The QT_DEBUG_PLUGINS only outputs the plugins that it opens but it does not show the failed attempts.
    Or am I missing something here?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What parameters are you giving to macdeployqt ?
    Can you also share your .pro file ?



  • @SGaist Thanks for the help.
    So I was using it like this: macdeployqt directory/to/bundle -verbose=3 -qmldir=directory/to/myapp/qml
    How should I share the .pro file? should I just copy the necessary parts here or do you need all of it?
    Since I have multiple libs that they get compiled with the app and also the build process is for Mac, Windows and Linux.
    I also have to say that I updated the Qt from 5.7.1 to 5.8 and now it works.
    But I would like to know what was the problem with 5.7.1 and if there is a bug in the Qt code.
    Thanks again for your help.


  • Lifetime Qt Champion

    Might be a glitch in the 5.7.1 version of macdeployqt. If you want to check then you should take a look at the change logs or compare the sources of macdeployqt.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.