How to manually create icns files using iconutil?

前端 未结 18 2082
无人共我
无人共我 2020-11-29 15:08

When I\'m validating my app I get this error:

the application bundle does not contain an icon in ICNS format, containing both a 512x512

18条回答
  •  甜味超标
    2020-11-29 15:35

    Same as @Henry (comment above) but takes as argument the PNG filename and outputs the ICNS with the same name.

    NOTE : The PNG file name is only expected to have 1 point to separate extension, i.e. xpto.png .

    So, save the code below to a filed called "CreateICNS.src" in the folder where your png file is.

    CODE :

    IFS='.' read -ra ADDR <<< "$1"
    ICONSET=${ADDR[0]}.iconset
    mkdir $ICONSET
    sips -z 16 16     $1 --out $ICONSET/icon_16x16.png
    sips -z 32 32     $1 --out $ICONSET/icon_16x16@2x.png
    sips -z 32 32     $1 --out $ICONSET/icon_32x32.png
    sips -z 64 64     $1 --out $ICONSET/icon_32x32@2x.png
    sips -z 128 128   $1 --out $ICONSET/icon_128x128.png
    sips -z 256 256   $1 --out $ICONSET/icon_128x128@2x.png
    sips -z 256 256   $1 --out $ICONSET/icon_256x256.png
    sips -z 512 512   $1 --out $ICONSET/icon_256x256@2x.png
    sips -z 512 512   $1 --out $ICONSET/icon_512x512.png
    cp $1 $ICONSET/icon_512x512@2x.png
    iconutil -c icns $ICONSET
    rm -R $ICONSET
    

    HOW TO USE :

    Then in the terminal, "cd" to the same folder and type :

    source CreateICNS.src {PNG filename}
    

    where {PNG filename} is the name of your PNG file, i.e. xpto.png .

    If your file would be named abc.png you would use :

    source CreateICNS.src abc.png
    

提交回复
热议问题