[Interest] Icons on macOS

Mitch Curtis mitch.curtis at qt.io
Tue Oct 9 07:11:56 CEST 2018


The Qbs docs state that there is no direct equivalent to ICON:

https://doc.qt.io/qbs/porting-to-qbs.html#icon

I’ve got this Qbs code that points to the .xcassets directory:

    Group {
        name: "macOS (icons)"
        condition: qbs.targetOS.contains("macos")
        files: ["images/logo/slate.xcassets"]
    }

This sets the icon name:

    Properties {
        condition: qbs.targetOS.contains("macos")
        ib.appIconName: "slate-icon-mac"
//        bundle.infoPlist: {
//            CFBundleIconFile: "images/logo/slate.xcassets/slate-icon-mac.appiconset"
//        }
    }

When you mentioned deploying the icon file to the app bundle I double-checked what was in the Resources directory:

    Assets.car
    slate-icon-mac.icns

So it seems to be there, albeit in the form of an icns file.. not sure what’s going on there.

On 10/8/18, 9:58 PM, "Artem Sidyakin" <artem.sidyakin at qt.io> wrote:

    With qmake project file it's just this one line, nothing else is required:
    
    ICON = icon.icns
    
    It will deploy the icon file to the app bundle and put the corresponding line into Info.plist.
    
    Unfortunately, I don’t know how it is done with Qbs as I never used it.
    
    ---
    Artem Sidyakin
    
    > On 8 Oct 2018, at 19:15, Mitch Curtis <mitch.curtis at qt.io> wrote:
    > 
    > I’m trying to add icons to an application on macOS. My Qbs file looks like this:
    > 
    > https://github.com/mitchcurtis/slate/tree/master/app/app.qbs
    > 
    > The generated assetcatalog_generated_info.plist file looks like this:
    > 
    > <?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>CFBundleIconFile</key>
    > 	<string>slate-icon-mac</string>
    > 	<key>CFBundleIconName</key>
    > 	<string>slate-icon-mac</string>
    > </dict>
    > </plist>
    > 
    > The contents of slate.xcassets:
    > 
    > https://github.com/mitchcurtis/slate/tree/master/app/images/logo/slate.xcassets
    > 
    > I don’t see the icon in the dock or anywhere else.
    > 
    > I saw this page:
    > 
    > http://doc.qt.io/qt-5/appicon.html#setting-the-application-icon-on-macos
    > 
    > It says:
    > 
    > “The application icon, typically displayed in the application dock area, is set by calling QWindow::setWindowIcon() on a window.”
    > 
    > However, the app that I’m basing my setup on doesn’t do that. It actually avoids macOS when it sets the window icon and yet still manages to get an icon to show up:
    > 
    > https://github.com/bjorn/tiled/blob/0b01a9c907e6cd6531204c32e36ea51af75f3bfc/src/tiled/mainwindow.cpp#L233
    > 
    > Another thing is that an asset catalog contains many .png files. I was under the impression that the point of it was for the OS to pick the correct image based on the metadata provided in the Contents.json file, so how would I know which size .png to set?
    > 
    > The rest of that page describes icns files, which the documentation explicitly says to avoid (https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/app-icon/), so it seems like it might be a bit out-dated.
    > 
    > So, how is this supposed to be done?
    > 
    > _______________________________________________
    > Interest mailing list
    > Interest at qt-project.org
    > http://lists.qt-project.org/mailman/listinfo/interest
    
    



More information about the Interest mailing list