IOS11 AppIcon cannot change

  • Xcode 9 beta 6
  • iOS 11 beta 10

    I want a batch application with a custom application icon, so I'm trying to replace AppIcon.png files with DerivedData (/Users/XXX/Library/Developer/Xcode/DerivedData/project/Build/Products/Debug-iphoneos/xxx.app)

    It worked in iOS 10 but does not work in iOS 11

    Can it be solved?

    Thanks for the promotion

+5
source share
1 answer

I have found a solution. I am changing application icons in the .xcasset source folder and not in Derived Data (using ImageMagick). So here is my script:

#!/bin/bash IFS=$'\n' BASE_ICONS_DIR=$(find ${SRCROOT}/${PRODUCT_NAME} -name "AppIcon.appiconset") IFS=$' ' CONTENTS_JSON="${BASE_ICONS_DIR}/Contents.json" version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"` # The next line adds special suffix, necessary in my project version="${version/'$(VERSION_SUFFIX)'/$VERSION_SUFFIX}" function tag() { export PATH=$PATH:/usr/local/bin:/opt/boxen/homebrew/bin/ ICON_PATH=$1 width=`identify -format %w ${ICON_PATH}` [ $? -eq 0 ] || exit 1 height=$((width * 30 / 100)) if [ "${CONFIGURATION}" != "AppStore" ]; then convert -background '#0008' \ -fill white -gravity center \ -size ${width}x${height} \ caption:"${version}" \ "${ICON_PATH}" +swap -gravity south -composite "${ICON_PATH}" || exit 1 fi } ICONS=(`grep 'filename' "${CONTENTS_JSON}" | cut -f2 -d: | tr -d ',' | tr -d '\n' | tr -d '"'`) ICONS_COUNT=${#ICONS[*]} IFS=$'\n' for (( i=0; i<ICONS_COUNT; i++ )); do tag "$BASE_ICONS_DIR/${ICONS[$i]}" done 

This script runs before Copy Bundle Resources . After the application icons are changed, I need to revert the changes using an additional script run as the last build phase:

 if [ "${CONFIGURATION}" != "AppStore" ]; then IFS=$'\n' git checkout -- `find "${SRCROOT}/${PRODUCT_NAME}" -name AppIcon.appiconset -type d` fi 

My build phases are as follows:

My build phases look like this

0
source

Source: https://habr.com/ru/post/1271637/


All Articles