MacOS: Problem setting the App Icon
-
wrote on 9 Mar 2023, 18:04 last edited by
Hello
I tried to set the app icon on Mac OS, but the "invalid icon" is superposed in front on my icon:
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
-
Hello
I tried to set the app icon on Mac OS, but the "invalid icon" is superposed in front on my icon:
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
Hi and welcome to devnet,
Did you also modify the
Info.plist
file as suggested here ? -
Hello
I tried to set the app icon on Mac OS, but the "invalid icon" is superposed in front on my icon:
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
wrote on 9 Mar 2023, 22:13 last edited by mpergand 3 Sept 2023, 22:17@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. -
wrote on 10 Mar 2023, 12:38 last edited by
@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 -
@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 previewwrote on 10 Mar 2023, 16:20 last edited by@Lonsdaleite
Maybe your icns is malformed, try to use an icon from another app to see if it works. -
@Lonsdaleite
Maybe your icns is malformed, try to use an icon from another app to see if it works.wrote on 10 Mar 2023, 16:43 last edited by@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
-
@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
wrote on 10 Mar 2023, 17:47 last edited by@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/7