Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS11 AppIcon can't change

Tags:

ios

ios11

  • Xcode 9 beta 6
  • iOS 11 beta 10

    I want package application with custom App icon , so I try to replace AppIcon.png files at DerivedData (/Users/XXX/Library/Developer/Xcode/DerivedData/project/Build/Products/Debug-iphoneos/xxx.app)

    It worked at iOS 10, but doesn't work at iOS 11

    Can anybody solve it?

    Thanks for advance

like image 372
Paladinfeng Avatar asked Sep 08 '17 10:09

Paladinfeng


People also ask

How do you change app icons on Iphone?

Tap on the icon under Home Screen Name and Icon. You'll have the choice of either taking a photo, choosing a photo, or choosing a file. Assuming you've already saved an image in Photo, tap on Choose Photo and select the photo you want to use.

What is the app that is purple with white star on it?

On an iPhone the iTunes Store app is the purple icon with the white star: There you can see prices of the albums and songs.


1 Answers

I have found a solution. I change app icons in the source .xcasset folder, 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 is executed before Copy Bundle Resources. After executing app icons are changed, so I need to revert changes with additional Run Script as a last Build Phase:

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

My Build Phases looks like this:

My Build Phases looks like this

like image 58
Valentin Shamardin Avatar answered Oct 15 '22 03:10

Valentin Shamardin