I have previously published my Qt app using Qt 5 + qmake.
I am now ready to release a new version using Qt 6 + CMake. (I am using Qt 6.4.2 and CMake 3.24.2)
However I am struggling to get app icons into Xcode 14.2 in a form that it will accept. Here are a couple of close examples.
In both cases, I have the following file structure for the app icons:
project-root
|- Images.xcassets
|- Contents.json
|- AppIcon.appiconset
|- Contents.json
|- AppIcon~iOS-Marketing-1024@1x.png
|- AppIcon~iPad-20@1x.png
|- AppIcon~iPad-20@2x.png
|- AppIcon~iPad-29@1x.png
|- AppIcon~iPad-29@2x.png
...
|- AppIcon~iPhone-60@2x.png
|- AppIcon~iPhone-60@3x.png
and both examples use the following CMake code
set_target_properties(MyApp PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_GUI_IDENTIFIER org.myorg.myapp
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
QT_IOS_LAUNCH_SCREEN "${CMAKE_CURRENT_SOURCE_DIR}/LaunchScreen.storyboard"
)
... code to include icons goes here ...
target_link_libraries(MyApp
PRIVATE Qt6::Quick)
install(TARGETS MyApp
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
In both examples, the app runs fine on my iPad and it can be archived, but the archive fails validation with the same errors:
Example 1
Here I include the icon image files directly (equivalent to how I did it with Qt 5 and Xcode 11(?)).
CMakeLists.txt
file(GLOB app_icon_files CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Images.xcassets/AppIcon.appiconset/*.png")
if (app_icon_files)
target_sources(MyApp PRIVATE ${app_icon_files})
set_source_files_properties(${app_icon_files} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
else()
message(WARNING "iOS app icon files not found")
endif()
Info.plist.in
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon~iPhone-20.png</string>
<string>AppIcon~iPhone-29.png</string>
<string>AppIcon~iPhone-40.png</string>
<string>AppIcon~iPhone-57.png</string>
<string>AppIcon~iPhone-60.png</string>
<string>AppIcon~iPad-20.png</string>
<string>AppIcon~iPad-29.png</string>
<string>AppIcon~iPad-40.png</string>
<string>AppIcon~iPad-76.png</string>
<string>AppIcon~iPad-83.5.png</string>
<string>AppIcon~iOS-Marketing-1024.png</string>
</array>
</dict>
</dict>
Results
- I can see the icon images individually listed in the project Resources folder.
- Xcode doesnāt show the icon against the project or target.
- However the app icon correctly appears on my iPad when I do a build and run in Xcode.
- When I build an archive and run āValidate appā, the icon shows up on the validation popup on the āReview MyApp.ipa contentā screen just before clicking āValidateā even though it didnāt show up against the archive in the list of archives.
Example 2
Here I include the image files as an asset catalog. I used the CMake code snippet below suggested by @craig.scott that he acknowledges is not officially supported by CMake to achieve this.
CMakeLists.txt
target_sources(MyApp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Images.xcassets")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Images.xcassets"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources
)
Info.plist.in
...
<key>CFBundleIconName</key>
<string>Images</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Images</string>
</array>
</dict>
</dict>
...
Results
- I can see the Images asset catalog in the project Resources folder. Clicking it shows the name AppIcon with the correct icon and a sheet of the icon at all different sizes, as it should be.
- Xcode doesnāt show the icon against the project or target.
- The app icon does not appear on my iPad when I do a build and run in Xcode.
- The icon does not appear anywhere in the archive or validation steps.
NB: changing the value for CFBundleIconName
to āAppIconā or removing this key entirely makes no difference.