我正在创建一个dmg文件,并在使用icns和png文件时得到以下错误。
这里是命令:
DeRez -only icns resources/test.icns > icns.rsrc错误:
/Applications/Xcode.app/Contents/Developer/usr/bin/DeRez - SysError -39在打开资源文件"resources/test.icns“期间
macOS版本:macOS mojave 10.14.2
请建议一下。
发布于 2021-07-05 18:22:26
刚才也遇到了这个问题,注意到这个问题没有得到回答,尽管它很简单。
显然,错误-39意味着end of file,我假设这意味着它无法找到预期的数据的有效部分。我猜您(像我一样)使用sips -i someicon.icns将文件的图标设置为自己?你应该得到一个错误的--addIcon is no longer supported,对我来说,这意味着它没有真正设置图标。因此,随后的DeRez调用获得一个.rsrc将失败。
我不想安装任何额外的东西,但幸运的是,我发现another answer on here似乎只使用标准的Xcode和/或macOS工具。在我的例子中,我试图设置一个AppleScript导出的.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文件设置自定义图标,但我想您已经知道如何将.rsrc“应用”到它了。=]
https://stackoverflow.com/questions/54708191
复制相似问题