Reputation: 321
I am creating a dmg file and getting following error while using the icns and png files..
Here is the command:
DeRez -only icns resources/test.icns > icns.rsrc
Error:
/Applications/Xcode.app/Contents/Developer/usr/bin/DeRez - SysError -39 during open of resource file "resources/test.icns"
Mac OS version: macOS mojave 10.14.2
Please suggest.
Upvotes: 1
Views: 709
Reputation: 339
Encountered this just now as well and noticed this question has gone unanswered, even though it's fairly simple.
Apparently error -39 means end of file
, I'm assuming this means it wasn't able to find a valid portion of expected data. I'm guessing you (like myself) used sips -i someicon.icns
to set the file's icon to itself? You should've gotten an error --addIcon is no longer supported
which to me means that it didn't actually set the icon. So a subsequent DeRez
call to get a .rsrc
out of it will fail.
I didn't want to install any extra stuff but luckily I found another answer on here that seems to use only standard Xcode and/or macOS tools. In my case I was trying to set an AppleScript-exported .app
icon, but the actual conversion part should be the same regardless.
So, all the steps to go from .png
to an actual icon for an .app
file:
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'
I haven't tried setting custom icons for a .dmg
file, but I guess you already know how to "apply" the .rsrc
to it anyways. =]
Upvotes: 0