iOS11 AppIcon无法更改

2024-04-17

  • Xcode 9 测试版 6
  • iOS 11 测试版 10

    我想要使​​用自定义应用程序图标打包应用程序,因此我尝试替换 DerivedData (/Users/XXX/Library/Developer/Xcode/DerivedData/project/Build/Products/Debug-iphoneos/xxx.app) 中的 AppIcon.png 文件

    它在 iOS 10 上工作,但在 iOS 11 上不起作用

    有人能解决吗?

    感谢您的提前


我找到了解决办法。 我在源 .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

我的构建阶段如下所示:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iOS11 AppIcon无法更改 的相关文章

随机推荐