iOS11 AppIcon无法更改

时间:2017-09-08 10:11:17

标签: ios ios11

  • Xcode 9 beta 6
  • iOS 11 beta 10

    我希望包应用程序带有自定义应用程序图标,因此我尝试在DerivedData上替换AppIcon.png文件(/Users/XXX/Library/Developer/Xcode/DerivedData/project/Build/Products/Debug-iphoneos/xxx.app )

    它适用于iOS 10,但不适用于iOS 11

    有人可以解决吗?

    感谢您提前

1 个答案:

答案 0 :(得分:3)

我找到了解决方案。 我在源.xcasset文件夹中更改应用程序图标,而不是在派生数据中(使用ImageMagick)。所以,这是我的脚本:

#!/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

此脚本在Copy Bundle Resources之前执行。执行应用程序图标后,我需要更改其他运行脚本作为最后一个构建阶段的更改:

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

我的构建阶段看起来像这样:

My Build Phases looks like this