Is it possible to get CMake to generate a macOS/iOS Xcode project that uses asset catalogs to set the application icon?
I’ve been trying to get it to work for days now without success, and I currently have the below code:
elseif(${TARGET_PLATFORM_FAMILY} STREQUAL Apple)
configure_file(templates/Info.plist ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
set(ICON_FILES
Assets.xcassets/
Assets.xcassets/Contents.json
Assets.xcassets/Appicon.appiconset/
Assets.xcassets/Appicon.appiconset/Contents.json
Assets.xcassets/Appicon.appiconset/Icon512.png
)
target_sources(${TARGETNAME} PRIVATE ${ICON_FILES})
source_group("Resources" FILES ${ICON_FILES})
set_target_properties(${TARGETNAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER ${APP_PACKAGE_ID}
XCODE_ATTRIBUTE_PRODUCT_NAME ${APP_DISPLAY_NAME}
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon;
XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES YES;
#RESOURCE "${ICON_FILES}"
)
When I open the generated project in Xcode I have an asset catalog folder and the Target/General page also sees the icon name (AppIcon) I set as valid (clicking on the grey arrow takes me to the asset catalog page with images appearing), but no matter what I try the app itself never gets the icon.