无法通过验证以在xcode中使用imagemagick和ghoscript更新我的应用图标

lrpiutwd  于 2023-01-14  发布在  其他
关注(0)|答案(1)|浏览(78)

我正在尝试更新我的应用程序的图标,以便能够区分它是在哪个环境中,我一直在这个tutorial和这些其他post的指导下与ImageMagick和Ghostscript一起工作有类似的问题,但我的问题是在我的脚本中的验证,但xcode他们表明我必须安装imagemagick和ghostscript,然而,我验证我有它正确安装,任何想法就如何修复它?
在报告导航器

的xcode中捕获到错误
已正确安装组件的计算机控制台

我附加了我正在使用的脚本

# 942v's Script
#!/bin/sh
export PATH=/opt/local/bin/:/opt/local/sbin:$PATH:/usr/local/bin:

convertPath=`which convert`
gsPath=`which gs`

if [[ ! -f ${convertPath} || -z ${convertPath} ]]; then
  convertValidation=true;
else
  convertValidation=false;
fi

if [[ ! -f ${gsPath} || -z ${gsPath} ]]; then
  gsValidation=true;
else
  gsValidation=false;
fi

if [[ "$convertValidation" = true || "$gsValidation" = true ]]; then
  echo "WARNING: Skipping Icon versioning, you need to install ImageMagick and ghostscript (fonts) first, you can use brew to simplify process:"

  if [[ "$convertValidation" = true ]]; then
    echo "brew install imagemagick"
  fi
  if [[ "$gsValidation" = true ]]; then
    echo "brew install ghostscript"
  fi
exit 0;
fi

buildPlist=$INFOPLIST_FILE

version="$MARKETING_VERSION"
build_num="$CURRENT_PROJECT_VERSION"

IMAGES_RIBBON="${SRCROOT}/CompileImages/${CONFIGURATION}.png"

caption="$build_num"
echo $caption

function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs -l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" ]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename \"$1\"`"; fi; fi; popd > /dev/null; }

function processIcon() {
    base_path=$1

    echo "base_path: $base_path"

    #this is the change
    target_path=$base_path

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

    band_height=$((($height * 20) / 100))
    band_position=$(($height - $band_height))
    text_position=$(($band_position - 3))
    point_size=$(((13 * $width) / 100))

    echo "Path: $IMAGES_RIBBON"
    echo "Image dimensions ($width x $height) - band height $band_height @ $band_position - point size $point_size"

    BASE_TMP_PATH="/tmp"

    #
    # blur band and text
    #
    convert $IMAGES_RIBBON -resize ${width}x${height} $BASE_TMP_PATH/ribbon.png

    convert ${base_path} -blur 10x8 $BASE_TMP_PATH/blurred.png
    convert $BASE_TMP_PATH/blurred.png -gamma 0 -fill white -draw "rectangle 0,$band_position,$width,$height" $BASE_TMP_PATH/mask.png
    convert -size ${width}x${band_height} xc:none -fill 'rgba(0,0,0,0.2)' -draw "rectangle 0,0,$width,$band_height" $BASE_TMP_PATH/labels-base.png
    convert -background none -size ${width}x${band_height} -pointsize $point_size -fill white -gravity center -gravity South caption:"$caption" $BASE_TMP_PATH/labels.png
    convert ${base_path} $BASE_TMP_PATH/blurred.png $BASE_TMP_PATH/mask.png -composite $BASE_TMP_PATH/temp.png

    rm $BASE_TMP_PATH/blurred.png
    rm $BASE_TMP_PATH/mask.png

    #
    # compose final image
    #
    filename=New${base_file}
    convert $BASE_TMP_PATH/temp.png $BASE_TMP_PATH/labels-base.png -geometry +0+$band_position -composite $BASE_TMP_PATH/labels.png -geometry +0+$text_position -geometry +${w}-${h} -composite $BASE_TMP_PATH/ribbon.png -composite "${target_path}"

    # clean up
    rm $BASE_TMP_PATH/temp.png
    rm $BASE_TMP_PATH/labels-base.png
    rm $BASE_TMP_PATH/labels.png
    rm $BASE_TMP_PATH/ribbon.png

    echo "Overlayed ${target_path}"
}



appiconset=$(find ${SRCROOT}/ -name AppIcon.appiconset)
echo "appiconset: $appiconset"

    if [ $CONFIGURATION = "Prod" ]; then
        find "$appiconset/icons/" -name '*.png' -exec cp '{}' "$appiconset/" \;
        echo "Exit"
        exit 0
    fi

if [ -d "$appiconset/icons/" ] 
then
    echo "Directory exists." 
    # get original icon to copy to assets
    find "$appiconset/icons/" -name '*.png' -exec cp '{}' "$appiconset/" \;
else
    # copy orgin to AppIcon
    rsync -rv  --include '*.png' --exclude '*' "$appiconset/" "$appiconset/icons/"
fi

for entry in "$appiconset"/*.png
do
  processIcon $entry
done
jckbn6z7

jckbn6z71#

根据注解,您指出从命令行运行which convert会得到/opt/homebrew/bin/convert的结果。
您的脚本将PATH设置为/opt/homebrew/bin以外的值。
更新脚本,使PATH设置如下:

export PATH=/opt/homebrew/bin:/opt/local/bin:/opt/local/sbin:$PATH:/usr/local/bin:

相关问题