iOS11 AppIcon无法更改 [英] iOS11 AppIcon can't change

查看:50
本文介绍了iOS11 AppIcon无法更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • Xcode 9 beta 6
  • iOS 11 beta 10

  • Xcode 9 beta 6
  • iOS 11 beta 10

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

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)

它在iOS 10上有效,但在iOS 11上无效

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

有人可以解决吗?

感谢前进

推荐答案

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

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

此脚本在 Copy Bundle Resources 之前执行.在执行应用程序图标后,更改了内容,因此在最后一个构建阶段,我需要使用其他运行脚本来还原更改:

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

我的构建阶段如下:

这篇关于iOS11 AppIcon无法更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆