gpt4 book ai didi

ios - 在 Xcode 9 中构建时更改 AppIcon

转载 作者:可可西里 更新时间:2023-11-01 17:13:09 24 4
gpt4 key购买 nike

我使用脚本在构建时生成应用程序图标(只需为 Debug模式添加“dev”标题)。使用 ImageMagick 和 Ghostscript(谷歌中有很多示例)非常容易。在我开始使用新的 Xcode 9 之前一切正常。现在,我可以在 MyAppName.app 文件上看到更新的图标,但模拟器/设备显示 Assets 中的 AppIcon。有什么建议么?谢谢

最佳答案

看起来,当 Xcode9 构建一个应用程序时,它现在将应用程序图标从 Assets 目录复制为私有(private)格式,并且不直接使用来自 bundle 的应用程序图标文件。这可能与新的 iOS11 功能有关,您可以在运行时更改应用程序图标。

有一个简单的修复方法。您需要做的是在 Assets 目录中直接更改您的应用程序图标,因此必须在您的build设置中进行 2 项更改:

<强>1。步骤 - 更新运行脚本阶段

更新您的“生成图标”运行脚本构建阶段,以便更新后的图标不会复制到目标包中,而是在 Assets 目录中更改图标。这是我的生成脚本的示例,请注意 target_path=$base_path 行:

function processIcon() {
export PATH=$PATH:/usr/local/bin
base_file=$1
base_path=`find ${SRCROOT}/Cards/Assets.xcassets -name $base_file`

if [[ ! -f ${base_path} || -z ${base_path} ]]; then
echo "failed to find base_path for $base_file"
return -1;
fi

target_file=`echo $base_file`

#this is the change
target_path=$base_path

echo $target_path

width=`identify -format %w ${base_path}`

convert -background '#0008' -fill white -gravity center -size ${width}x40 caption:"${version} (${build}) ${commit}" ${base_path} +swap -gravity south -composite ${target_path}
}

<强>2。 step - 改变构建阶段的顺序

您必须更改构建阶段的顺序,以便“生成图标”构建阶段“复制捆绑资源”构建阶段之前排序: changed order of build phases

原创思路和脚本代码来自Krzysztof Zabłocki's blog post .

关于ios - 在 Xcode 9 中构建时更改 AppIcon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45731001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com