1

I've created an AppleScript .app file in Script Debugger.app.

I assigned a custom icon to this .app file by pasting a new icon over the default icon in the application's Get Info window in Finder. The custom icon is set immediately.

However, when I open the app in Script Debugger or Script Editor, to edit the code, and then resave the file, the custom icon disappears.

On save, the following icon immediately takes the place of the custom icon:

Of course, having to go through the process of setting the custom icon every time that I save (i.e., edit) the file is an inconvenience.

Is there a way for my custom application icon to remain in place, even after the .app file has been modified?


Here is a similar post:

App made in Applescript; Icon won't change

The answer to the above post gave me the idea to delete the default icon file located at /Contents/Resources/applet.icns (which I accessed by right-clicking the .app file in Finder and clicking the Show Package Contents context menu item). I then pasted my custom icon into this Resources folder, and renamed my icon applet.icns.

The effect of this was a custom icon in informational dialogs in my AppleScript application, but it did not actually change the actual application icon (i.e., the icon that is inserted into the Dock while the application is running). But, at least this custom dialog icon did remain in place upon re-saving/editing the AppleScript code.

2

I followed your exact same procedure and found the exact same problem on operating system Sierra as well. After trying a few things I decided (in addition to changing the main Applications icon in the get info window) to do the exact same thing in the get info window of the applet.icns file and change it's icon as well. I then opened that script editor app in scripteditor and saved the file. The new icons remained as I changed them. Tested in script debugger also and my custom icons remained untouched.

enter image description here

UPDATE:

This following AppleScript code will permanently change the default applet.icns file of your AppleScript applets to any other .icns file of your choosing so that even after editing and re-saving the AppleScript applet, your custom icon will be retained.

property destinationSuffix : "Contents/Resources/applet.icns"

activate
set chosenApp to (choose file with prompt ¬
    "Choose The Application Whose Icon You Would Like To Change" of type ¬
    "APPL" with multiple selections allowed)

activate
set iconFile to (choose file of type "com.apple.icns" with prompt ¬
    "Choose The Replacement .icns File")

repeat with thisItem in chosenApp
    set replaceThisIcon to POSIX path of thisItem & destinationSuffix 
    try
        do shell script "cp " & quoted form of POSIX path of iconFile & " " & ¬
            quoted form of replaceThisIcon & " ; touch " & quoted form of POSIX path of thisItem
    end try
end repeat
5
  • Pasting my custom icon as the file icon of the applet.icns file solves the issue. Now when I edit the AppleScript code and re-save the .app, the application's custom file icon is no longer overwritten with the default icon. Thanks! May 30 '17 at 17:09
  • Yes I’m fully aware choose file is from Standard Additions. Come on, that’s an AppleScript 101 lesson LOL. I sent choose file command to Finder, as a workaround to a problem I am STUMPED by. I don’t know if it’s an AppleScript or an OS bug or just a bug that happens on my system and it’s setup, but for some reason when I use choose file through Standard Additions, when the window to actually choose the file appears, it freezes. After 30 or 40 seconds or so, I can eventually select a file but if I need to scroll down or something, it freezes again for an additional 30 seconds or so.
    – wch1zpink
    Jun 20 at 2:15
  • continued… The problem only occurs when I run the compiled and saved script through the script menu in the menubar. It does not happen when I run the code through Debugger or Editor.
    – wch1zpink
    Jun 20 at 2:35
  • Latest release of macOS Big Sur
    – wch1zpink
    Jun 20 at 3:13
  • It works without issue for me in macOS Big Sur 11.4. Have you tried it booted to safe mode? Jun 20 at 3:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .