MacOS – Error while using setfile to set icon for dmg created via hdiutil in mac

dmgiconmacos

I have created an app & signed using "Developer ID Application: x" certificate. then using hdiutil i created the dmg

hdiutil create -size 1.5m -format UDRW myapp.dmg -srcfolder ./myapp/ -fs HFS+

to set the drive icons when i execute the below commandsit throws the error

# custom drive volume icon..
#cp drive_icon.icns /Volumes/myapp/.VolumeIcon.icns
#SetFile -c icnC /Volumes/myapp/.VolumeIcon.icns //(throws error -5000)
dev:Unexpected error. (-5000) on file: /Volumes/myapp/.VolumeIcon.icns

I thought it would be related to size and increased the size of dmg from 1.5m to 4.5m but that also not helps, image size is 291kb and the overall app size is 666kb.

I created the .app in build machine (mac 10.10 xcode6.2), and tried creating this hdutil in our codesigning server (mac 10.11). can anyone tell me where it went wrong.

In the man page I see setfile is deprecated is there any other equivalent command to do

Thanks and Regards, Saravana

Best Answer

found another way to set icon. Right click the DMG file and click "GetInfo" Drag and drop the icon file to the icon location present in the GetInfo dialog box. it sets.

Thanks and regards, Saravana