10

I have created my AppleScript, tested it, saved it as an .app and it works.

Now, how do I set a custom icon for it?

I have done a bit of googling and tried a few different things but cannot get it to work. The app is mainly for me and maybe some people I know to make workflows easier so having a nice little icon makes a huge difference. Can anyone help with this please?

jgraup
  • 1,271
  • 12
  • 14
Adam Mann Pro
  • 255
  • 1
  • 3
  • 12

5 Answers5

22
  • Basically you need an .icns icon file.
  • Open your application with right-click > Show Package Contents
  • Navigate to Contents > Resources
  • Delete applet.icns
  • Drag the custom icon file into the Resources folder
  • Rename the icon file in Resources to applet.icns
  • To update the icon appearance open and re-save the applet in Script Editor.
vadian
  • 274,689
  • 30
  • 353
  • 361
  • I did try that but I will try again with a newly generated .icns file – Adam Mann Pro Mar 15 '17 at 16:30
  • Where do you create an `.icns` file? – jgraup Mar 17 '17 at 13:32
  • 3
    You need a set of icon images in different sizes (see https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html) and the `iconutil` executable (in /usr/bin). See also http://stackoverflow.com/questions/6337787/how-can-i-set-the-icon-for-a-mac-application-in-xcode – vadian Mar 17 '17 at 14:30
  • What is the recommended resolution for the applescript icon? The links to the Apple documentation only talks about a regular XCode app, not a AppleScript app. – Nrc Oct 01 '19 at 09:49
  • @Nrc Honestly I don't know. I guess you don't need the 1024x1024 resolution – vadian Oct 01 '19 at 09:58
  • 1
    `mkdir MyIcon.iconset` then put in both files, icon_512x512.png and icon_512x512@2x.png The run `iconutil -c icns MyIcon.iconset` then put resulting icns in place of your applet.icns – JAnton Apr 15 '21 at 23:55
21

This is how I do it:

  1. In Finder, select your icon file.
  2. Get Info (CMD-I) on the file.
  3. Click the icon in the top left corner of the Get Info window.
  4. Copy it via CMD-C.
  5. Now Get Info on your AppleScript file.
  6. Click the icon in the top left corner of the Get Info window.
  7. Paste the icon using CMD-V.

The AppleScript icon should be replaced by the icon copied from the icon file.

A screen recording demonstrating this process can be viewed at this answer from AskDifferent.

pipwerks
  • 4,440
  • 1
  • 20
  • 24
  • This worked quickly and without fuss. Thank-you. Saved myself a bit of time by processing my image through http://realfavicongenerator.net/ first. – jgraup Mar 17 '17 at 13:34
  • This is the better solution. – Zachary David Saunders Dec 18 '17 at 23:49
  • @Zachary David Saunders For some files such as .scpt files, this is the only solution because there is no resources folder containing an applet.icns file (as in the solution by vadian .. Which is also a permanent solution) However, the method described in this answer is temporary. Any time you change an applet's icon using the method described in this answer, and that applet is reopened, edited, and saved in Script Editor... It will revert back to its default icon. So how could this possibly be the better solution? – wch1zpink Aug 05 '19 at 01:42
1

Just building into @pipwerks answers: You can also use Drag&Drop!

  • (Optional) Create your icon online from any image on https://iconverticons.com/online/ and download de .icns file for your icon.
  • Get Info (CMD-I) on you AppleScript file.
  • Now Drag&Drop your .icns file into the small icon in the top left corner.

It works and now it's ready to add it to the dock or wherever you want.

Javier B
  • 11
  • 4
1

On newer systems if the above methods do not work there is another solution.

In Script Editor, after opening our script (.app), choose View -> Show Bundle Contents from the menu (or press cmd +0).

In the panel that will expand on the right (Bundle Info) in the Resources section, right-click the applet.icns file and select delete from the drop-down menu.

Our new icon file with the same name applet.icns drag and drop into the window Resources where you just deleted it.

Save application and voila :-D

Stephan Hogenboom
  • 1,543
  • 2
  • 17
  • 29
Lazarus
  • 11
  • 3
0

Here's another way on newer systems, I'm using macOS 12.1.

Open the new icon image file in Preview and choose File > Export...

Hold down the Option key while selecting "Format" and see a whole bunch of new choices including ICNS.

Save it, drop it in your Resources folder, and you're good to go.

dustin555
  • 31
  • 2