Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MacOS: Problem setting the App Icon
Forum Updated to NodeBB v4.3 + New Features

MacOS: Problem setting the App Icon

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 938 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lonsdaleite
    wrote on 9 Mar 2023, 18:04 last edited by
    #1

    Hello

    I tried to set the app icon on Mac OS, but the "invalid icon" is superposed in front on my icon:
    alt text

    The icon file is correctly inside the package

    Any idea on the cause of the problem ?

    Here is the .PRO line :
    macx {
    ICON += icon.icns
    QMAKE_INFO_PLIST = Info.plist
    RESOURCE_FILES.files = $$ICON
    RESOURCE_FILES.path = Contents/Resources
    QMAKE_BUNDLE_DATA += RESOURCE_FILES
    }

    and in the ui : setWindowIcon(QIcon("icon.icns"));

    Thanks you very much

    S M 2 Replies Last reply 9 Mar 2023, 19:44
    0
    • L Lonsdaleite
      9 Mar 2023, 18:04

      Hello

      I tried to set the app icon on Mac OS, but the "invalid icon" is superposed in front on my icon:
      alt text

      The icon file is correctly inside the package

      Any idea on the cause of the problem ?

      Here is the .PRO line :
      macx {
      ICON += icon.icns
      QMAKE_INFO_PLIST = Info.plist
      RESOURCE_FILES.files = $$ICON
      RESOURCE_FILES.path = Contents/Resources
      QMAKE_BUNDLE_DATA += RESOURCE_FILES
      }

      and in the ui : setWindowIcon(QIcon("icon.icns"));

      Thanks you very much

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Mar 2023, 19:44 last edited by
      #2

      Hi and welcome to devnet,

      Did you also modify the Info.plist file as suggested here ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply 10 Mar 2023, 12:38
      0
      • L Lonsdaleite
        9 Mar 2023, 18:04

        Hello

        I tried to set the app icon on Mac OS, but the "invalid icon" is superposed in front on my icon:
        alt text

        The icon file is correctly inside the package

        Any idea on the cause of the problem ?

        Here is the .PRO line :
        macx {
        ICON += icon.icns
        QMAKE_INFO_PLIST = Info.plist
        RESOURCE_FILES.files = $$ICON
        RESOURCE_FILES.path = Contents/Resources
        QMAKE_BUNDLE_DATA += RESOURCE_FILES
        }

        and in the ui : setWindowIcon(QIcon("icon.icns"));

        Thanks you very much

        M Offline
        M Offline
        mpergand
        wrote on 9 Mar 2023, 22:13 last edited by mpergand 3 Sept 2023, 22:17
        #3

        @Lonsdaleite
        Could be tricky ...

        Check if the icns format is valid (load correctly in Preview ?)
        Check if the info.plist of the app bundle in the build folder has the right icon entry:

        <key>CFBundleIconFile</key>
        <string>icon.icns</string>
        

        if not, trash the build folder and rebuild & run
        In last attempt, rebooting can make the icon to appear in the finder.

        1 Reply Last reply
        0
        • S SGaist
          9 Mar 2023, 19:44

          Hi and welcome to devnet,

          Did you also modify the Info.plist file as suggested here ?

          L Offline
          L Offline
          Lonsdaleite
          wrote on 10 Mar 2023, 12:38 last edited by
          #4

          @SGaist said in MacOS: Problem setting the App Icon:

          Hi and welcome to devnet,

          Did you also modify the Info.plist file as suggested here ?

          Here is the original info.plist (i copied it from the generatred bundle for iOS, perhaps the problem come from here ?)

          <?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>CFBundleDisplayName</key>
                  <string>BIL</string>
          	<key>CFBundleExecutable</key>
          	<string>${EXECUTABLE_NAME}</string>
          	<key>CFBundleIconFile</key>
                  <string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
          	<key>CFBundleIdentifier</key>
                  <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
          	<key>CFBundleName</key>
                  <string>BIL</string>
          	<key>CFBundlePackageType</key>
          	<string>APPL</string>
          	<key>CFBundleShortVersionString</key>
          	<string>${QMAKE_SHORT_VERSION}</string>
          	<key>CFBundleSignature</key>
          	<string>${QMAKE_PKGINFO_TYPEINFO}</string>
                  <key>CFBundleVersion</key>
          	<string>${QMAKE_FULL_VERSION}</string>
          	<key>LSRequiresIPhoneOS</key>
          	<true/>
          	<key>MinimumOSVersion</key>
          	<string>${IPHONEOS_DEPLOYMENT_TARGET}</string>
          	<key>NOTE</key>
          	<string>This file was generated by Qt/QMake.</string>
          	<key>UILaunchStoryboardName</key>
          	<string></string>
          	<key>UISupportedInterfaceOrientations</key>
          	<array>
          		<string>UIInterfaceOrientationPortrait</string>
          	</array>
          </dict>
          </plist>
          

          And here is the final info.plist inside the bundle

          <?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>CFBundleDisplayName</key>
                  <string>BIL</string>
          	<key>CFBundleExecutable</key>
          	<string>BIL</string>
          	<key>CFBundleIconFile</key>
                  <string>icon.icns</string>
          	<key>CFBundleIdentifier</key>
                  <string>test.BIL</string>
          	<key>CFBundleName</key>
                  <string>BIL</string>
          	<key>CFBundlePackageType</key>
          	<string>APPL</string>
          	<key>CFBundleShortVersionString</key>
          	<string>1.0</string>
          	<key>CFBundleSignature</key>
          	<string>????</string>
                  <key>CFBundleVersion</key>
          	<string>1.0.0</string>
          	<key>LSRequiresIPhoneOS</key>
          	<true/>
          	<key>MinimumOSVersion</key>
          	<string></string>
          	<key>NOTE</key>
          	<string>This file was generated by Qt/QMake.</string>
          	<key>UILaunchStoryboardName</key>
          	<string></string>
          	<key>UISupportedInterfaceOrientations</key>
          	<array>
          		<string>UIInterfaceOrientationPortrait</string>
          	</array>
          </dict>
          </plist>
          

          @mpergand
          I tried to rebuild & run many times and reboot too.
          The .icns is correctly inside the bundle and on the preview

          M 1 Reply Last reply 10 Mar 2023, 16:20
          0
          • L Lonsdaleite
            10 Mar 2023, 12:38

            @SGaist said in MacOS: Problem setting the App Icon:

            Hi and welcome to devnet,

            Did you also modify the Info.plist file as suggested here ?

            Here is the original info.plist (i copied it from the generatred bundle for iOS, perhaps the problem come from here ?)

            <?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>CFBundleDisplayName</key>
                    <string>BIL</string>
            	<key>CFBundleExecutable</key>
            	<string>${EXECUTABLE_NAME}</string>
            	<key>CFBundleIconFile</key>
                    <string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
            	<key>CFBundleIdentifier</key>
                    <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
            	<key>CFBundleName</key>
                    <string>BIL</string>
            	<key>CFBundlePackageType</key>
            	<string>APPL</string>
            	<key>CFBundleShortVersionString</key>
            	<string>${QMAKE_SHORT_VERSION}</string>
            	<key>CFBundleSignature</key>
            	<string>${QMAKE_PKGINFO_TYPEINFO}</string>
                    <key>CFBundleVersion</key>
            	<string>${QMAKE_FULL_VERSION}</string>
            	<key>LSRequiresIPhoneOS</key>
            	<true/>
            	<key>MinimumOSVersion</key>
            	<string>${IPHONEOS_DEPLOYMENT_TARGET}</string>
            	<key>NOTE</key>
            	<string>This file was generated by Qt/QMake.</string>
            	<key>UILaunchStoryboardName</key>
            	<string></string>
            	<key>UISupportedInterfaceOrientations</key>
            	<array>
            		<string>UIInterfaceOrientationPortrait</string>
            	</array>
            </dict>
            </plist>
            

            And here is the final info.plist inside the bundle

            <?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>CFBundleDisplayName</key>
                    <string>BIL</string>
            	<key>CFBundleExecutable</key>
            	<string>BIL</string>
            	<key>CFBundleIconFile</key>
                    <string>icon.icns</string>
            	<key>CFBundleIdentifier</key>
                    <string>test.BIL</string>
            	<key>CFBundleName</key>
                    <string>BIL</string>
            	<key>CFBundlePackageType</key>
            	<string>APPL</string>
            	<key>CFBundleShortVersionString</key>
            	<string>1.0</string>
            	<key>CFBundleSignature</key>
            	<string>????</string>
                    <key>CFBundleVersion</key>
            	<string>1.0.0</string>
            	<key>LSRequiresIPhoneOS</key>
            	<true/>
            	<key>MinimumOSVersion</key>
            	<string></string>
            	<key>NOTE</key>
            	<string>This file was generated by Qt/QMake.</string>
            	<key>UILaunchStoryboardName</key>
            	<string></string>
            	<key>UISupportedInterfaceOrientations</key>
            	<array>
            		<string>UIInterfaceOrientationPortrait</string>
            	</array>
            </dict>
            </plist>
            

            @mpergand
            I tried to rebuild & run many times and reboot too.
            The .icns is correctly inside the bundle and on the preview

            M Offline
            M Offline
            mpergand
            wrote on 10 Mar 2023, 16:20 last edited by
            #5

            @Lonsdaleite
            Maybe your icns is malformed, try to use an icon from another app to see if it works.

            L 1 Reply Last reply 10 Mar 2023, 16:43
            0
            • M mpergand
              10 Mar 2023, 16:20

              @Lonsdaleite
              Maybe your icns is malformed, try to use an icon from another app to see if it works.

              L Offline
              L Offline
              Lonsdaleite
              wrote on 10 Mar 2023, 16:43 last edited by
              #6

              @mpergand I don't have another .icns, so i copied the Qt icns, and the problem is always here.
              Is there any problem in the info.plist that cause a problem ?
              I think i will try to write the info.plist on my own instead of copied one.

              I keep you posted

              L 1 Reply Last reply 10 Mar 2023, 17:47
              0
              • L Lonsdaleite
                10 Mar 2023, 16:43

                @mpergand I don't have another .icns, so i copied the Qt icns, and the problem is always here.
                Is there any problem in the info.plist that cause a problem ?
                I think i will try to write the info.plist on my own instead of copied one.

                I keep you posted

                L Offline
                L Offline
                Lonsdaleite
                wrote on 10 Mar 2023, 17:47 last edited by
                #7

                @Lonsdaleite I created my own info.plist instead of copied the file generated with the xcode package for iOS and it solved the problem. Don't know why, but it works !

                Thanks for you response.

                Little question for the end : i created an icon catalog assets which include both iOS and macOS Icon (required for iOS if i understand all ?). Can i use it for Mac bundle instead of .icns ?

                1 Reply Last reply
                0
                • L Lonsdaleite has marked this topic as solved on 10 Mar 2023, 17:47

                1/7

                9 Mar 2023, 18:04

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved