我正在创建dmg文件,并在使用icns和png文件时出现以下错误。.
以下是命令:
DeRez -only icns resources/test.icns > icns.rsrc
错误:
/Applications/Xcode.app/Contents/Developer/usr/bin/DeRez-SysError -39在打开资源文件“ resources / test.icns”期间
Mac OS版本:macOS mojave 10.14.2
请提出建议。
答案 0 :(得分:0)
刚才也遇到了这个问题,注意到这个问题没有答案,尽管它很简单。
显然错误 -39 意味着 temp
,我假设这意味着它无法找到预期数据的有效部分。我猜你(像我一样)使用 end of file
将文件的图标设置为自身?您应该收到错误 sips -i someicon.icns
,这对我来说意味着它实际上并未设置图标。因此,随后的 --addIcon is no longer supported
调用以从中获取 DeRez
将失败。
我不想安装任何额外的东西,但幸运的是我发现 another answer on here 似乎只使用标准的 Xcode 和/或 macOS 工具。就我而言,我试图设置 AppleScript 导出的 .rsrc
图标,但无论如何实际转换部分应该是相同的。
因此,从 .app
到 .png
文件的实际图标的所有步骤:
.app
我还没有尝试为 cd /some/application/dir/some.app/Contents/Resources
cp /some/assets/dir/myicon.png ./
# Convert png to icns
# Keep in mind that sips can allegedly only handle 256x256, 512x512 and 1024x1024 PNGs for this
# Otherwise you need to do something like the following first:
# sips -z 256 256 myicon.png --out myicon_resized.png
# Then check if it came out good and run:
# mv -f myicon_resized.png myicon.png
# Now let's actually convert it and remove the png as it's no longer needed
sips -s format icns myicon.png --out myicon.icns
rm -fv myicon.png
# Apparently you can also specify commands of some sort in .rsrc files (this is the part I needed from the other SO answer)
# This is used in place of DeRez
echo "read 'icns' (-16455) \"myicon.icns\";" > myicon.rsrc
# Now just use Rez to append it to the special icon file in the root of the .app dir
Rez -append myicon.rsrc -o $'../../Icon\r'
# Write the metadata indicating we want to use the Icon\r file for the app's icon
# I could just use ../../ for the path but I like to be explicit
SetFile -a C ../../../some.app
# Also hide said file from Finder views
SetFile -a V $'../../Icon\r'
文件设置自定义图标,但我想您已经知道如何“应用”.dmg
。 =]