Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
@19h

This comment has been minimized.

Copy link

@19h 19h commented Jun 4, 2014

Pretty sweet. Saved the face of my dock after I migrated to OS X Yosemite DP1 from Mavericks.

@scherii

This comment has been minimized.

Copy link

@scherii scherii commented Jul 9, 2014

Unfortunately it doesn't help with the invisible Finder icons (Yosemite DP1-3)

@inket

This comment has been minimized.

Copy link

@inket inket commented Jul 10, 2014

@scherii This worked for me on Yosemite DP3!
It's what I needed to do after replacing folder icons with LiteIcon.

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;
sudo mv /Library/Caches/com.apple.iconservices.store com.apple.ic

Just being careful on the last one (renaming instead of removing)

@NotAlexNoyle

This comment has been minimized.

Copy link

@NotAlexNoyle NotAlexNoyle commented Aug 11, 2014

Thank you! This helped with my issue. Was trying to install Java 8, which requires "10.7+". I guess it recognized 10.10 as 10.1.0 and wouldn't let me install it. I had to edit my systemversion.plist to install it, (risky and stupid); and it messed up my icons even after I reverted the .plist to 10.10 after installing.

This command fixed it! I really do appreciate you posting this.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Oct 18, 2014

If you only want to update one Application icon, ie, in App.app/Contents/Resources/App.icns just touch the App.app folder. (I've read you need to do the Info.plist as well sometimes, although I've never needed to.)

Close the finder windows and:

touch /Applications/App.app
touch /Applications/App.app/Contents/Info.plist

You can refresh the dock icon cache using the commands above, also do a killall Dock to restart it. Personally I would just drag the application in question, off the dock and re-start / keep in dock, because this is generally a one off thing. As always, script it if possible / and you're doing it a lot.

@mabbbbbbbbbbb

This comment has been minimized.

Copy link

@mabbbbbbbbbbb mabbbbbbbbbbb commented Dec 31, 2014

@jasonm23 Nice!

touch /Applications/App.app
@MarkLeMerise

This comment has been minimized.

Copy link

@MarkLeMerise MarkLeMerise commented Mar 5, 2015

@jasonm23 Worked perfectly! Thank you!

touch /Applications/App.app
touch /Applications/App.app/Contents/Info.plist
killall Dock
@Ardakilic

This comment has been minimized.

Copy link

@Ardakilic Ardakilic commented Mar 23, 2015

@jasonm23 Thanks, worked flawlessly!

@Robpol86

This comment has been minimized.

Copy link

@Robpol86 Robpol86 commented Apr 2, 2015

@jasonm23 very nice, almost TOO easy.

@FelixAkk

This comment has been minimized.

Copy link

@FelixAkk FelixAkk commented Apr 19, 2015

@jasonm23 Simple and for me the first trick that does work. Superthanks! :)

@tcelestino

This comment has been minimized.

Copy link

@tcelestino tcelestino commented May 9, 2015

why?
Imgur

Oo

@binaryrefinery

This comment has been minimized.

Copy link

@binaryrefinery binaryrefinery commented May 17, 2015

@tcelestino you need to replace 'App.app' in your command with the application name you want to 'touch' (eg. Evernote.app)

@dessalines

This comment has been minimized.

Copy link

@dessalines dessalines commented Jun 15, 2015

The touch commands worked for me! Thanks

@spotcatbug

This comment has been minimized.

Copy link

@spotcatbug spotcatbug commented Nov 18, 2015

Awesome. I've had a generic app icon for a particular app and it's been bugging me for months. I finally hit on the correct Google search and ended up here.

touch is the secret sauce.

@orome

This comment has been minimized.

Copy link

@orome orome commented Dec 4, 2015

Changing (and applying) app settings using whatever UI the app provides for doing so may also work (effectively this will do what touch does, but without possible side effects that makes the app unhappy).

@dkmn

This comment has been minimized.

Copy link

@dkmn dkmn commented Jan 30, 2016

Thanks, this was very helpful. I recently had corruption of almost every Application icon (unable to launch) after upgrading to 10.11.3.
After many maneuvers, I eventually fixed that by rebuilding the "Launch Services" database with Onyx.
However, the Dock icons were still corrupt. Running your script here and then "killall Dock" fixed the problem.

@legomind

This comment has been minimized.

Copy link

@legomind legomind commented Feb 6, 2016

Worked for me after updating to 10.11.3. Thanks!

@kaishin

This comment has been minimized.

Copy link

@kaishin kaishin commented Feb 12, 2016

Nice tip.

@chuyik

This comment has been minimized.

Copy link

@chuyik chuyik commented Feb 19, 2016

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
sudo find /private/var/folders -name com.apple.iconservices -exec rm -rf {} \;   # Without `/` after `folders`

This two commands are helpful!
Works on 10.11

@ProbonoBonobo

This comment has been minimized.

Copy link

@ProbonoBonobo ProbonoBonobo commented Mar 11, 2016

@jasonm23

+1. Thanks for the tip!

@iMattPro

This comment has been minimized.

Copy link

@iMattPro iMattPro commented Mar 16, 2016

Thanks.. This fixed my issue: Fresh installed El Capitan, installed apps, migrated over documents. Some document icons displayed as a blank generic file (but only when displayed as a small icon).

This command worked fine. Just know you need to enter user password for it at the prompt.

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;

This one failed for me, I think it couldn't find it.

sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;

This resulted in an odd folder in my user's home directory which I just deleted.
screen shot 2016-03-16 at 8 31 04 am

sudo mv /Library/Caches/com.apple.iconservices.store com.apple.ic
@skipjackyu

This comment has been minimized.

Copy link

@skipjackyu skipjackyu commented Mar 23, 2016

Now I want to find an App's icns that I once replaced but I don't know where it is.I know that the DEFAULT .icns is in the /Applications/app.app folders.

@Falven

This comment has been minimized.

Copy link

@Falven Falven commented Apr 26, 2016

The two commands above did not work for me on OS X 10.11.4. After running them, and resetting my machine, my file icons are still of an old app I uninstalled.

@malyw

This comment has been minimized.

Copy link

@malyw malyw commented Oct 1, 2016

sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;
sudo rm -rf /Library/Caches/com.apple.iconservices.store
killall Dock

worked for me on OSX El Capitan

@richardackroyd

This comment has been minimized.

Copy link

@richardackroyd richardackroyd commented Oct 29, 2016

+1 for chuyik on Yosemite - ran both finds (split down to a find and manual removal - call me paranoid) - following by killall Dock and everything back to normal after some very screwy corrupted icons

@toufikhamdani

This comment has been minimized.

Copy link

@toufikhamdani toufikhamdani commented Nov 3, 2016

Hello,

I'm trying with the Notes app but it doesn't work for me :
Toufiks-MacBook-Pro:~ administrator$ touch /Applications/Notes.app
touch: /Applications/Notes.app: Operation not permitted

screenshot at nov 03 16-07-34

@beyondthetech

This comment has been minimized.

Copy link

@beyondthetech beyondthetech commented Nov 7, 2016

+1 for malyw.

sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} ;
sudo rm -rf /Library/Caches/com.apple.iconservices.store
killall Dock
killall Finder

Only when I restarted the Finder did the above work for me in Sierra 10.12.1

@DonRichards

This comment has been minimized.

Copy link

@DonRichards DonRichards commented Dec 8, 2016

+1 for malyw & beyondthetech

sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} ;
sudo rm -rf /Library/Caches/com.apple.iconservices.store
killall Dock
killall Finder

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jan 2, 2017

Thanks everyone. Here is a combined single-line command which should work on both old and new macOS versions:

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3; killall Dock; killall Finder
@liquidfrollo

This comment has been minimized.

Copy link

@liquidfrollo liquidfrollo commented Jan 5, 2017

The original version worked for me on OSX sierra for finder and launchpad. I ran the command and did killall Dock and everything is back to normal! thanks.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jan 10, 2017

@liquidfrollo My command above is literally a combination of all commands ever mentioned above. As a oneliner. So it will work on every OS.

But even that command doesn’t fix all cached icons. So another way to solve it is to Get Info, drag a different icon to the icon area, then press Backspace to remove the other icon and “revert” to what is in the app bundle. That will always make the correct icon refresh.

@bernex

This comment has been minimized.

Copy link

@bernex bernex commented Feb 4, 2017

Hi,
can we do it for one application not global clear cache?

@bernex

This comment has been minimized.

Copy link

@bernex bernex commented Feb 4, 2017

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3; killall Dock; killall Finder

do not help me in Sierra (

Finder have new icon, but Dockers icon is same (

@Niresh12495

This comment has been minimized.

Copy link

@Niresh12495 Niresh12495 commented Feb 18, 2017

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
This will work
Clear macOS icon cache

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Mar 4, 2017

GUYS! After years of trying the commands above (literally, 2-3 years), with almost no success due to macOS strong caching. I've discovered that the BEST, most RELIABLE way to rebuild the icon cache in macOS is to right click the app, "Get Info", drag ANYTHING to its icon in the top left of the "Get Info" window (you can drag a FOLDER to its icon if you want to) to assign a new temporary icon, then CLICK the icon in the "get info" window and press BACKSPACE to clear it. Now that forces macOS to re-read the .icns file inside the bundle itself. And will cache the new one. Far more reliable than any attempts to clear caches. None of the commands above have ever worked for me. But my solution works every time!

@unculcated

This comment has been minimized.

Copy link

@unculcated unculcated commented Mar 10, 2017

good job thanks

@ramiroaraujo

This comment has been minimized.

Copy link

@ramiroaraujo ramiroaraujo commented Mar 16, 2017

@SteveJobzniak hahahah, I love the bold fat text explaining this simple solution :) I've had the same issue for ages, and indeed solved it with this simple trick
Thanks!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Mar 28, 2017

@ramiroaraujo Haha. Sometimes shouting is needed. ^_^

@sytxerr

This comment has been minimized.

Copy link

@sytxerr sytxerr commented Jun 7, 2017

@SteveJobzniak you save my day bro... :)

@thedev5

This comment has been minimized.

Copy link

@thedev5 thedev5 commented Jun 11, 2017

I fixed it by going in the activity monitor and shutting down WindowServer. I just did it under inspiration, no idea if it's what fixed the problem, however you can try!

@elgs

This comment has been minimized.

Copy link

@elgs elgs commented Jun 19, 2017

@SteveJobzniak saved my butt. Thanks.

@sinedsem

This comment has been minimized.

Copy link

@sinedsem sinedsem commented Jun 22, 2017

@SteveJobzniak perfect!

@astrostl

This comment has been minimized.

@ActionScripted

This comment has been minimized.

Copy link

@ActionScripted ActionScripted commented Aug 22, 2017

@jeffersonsetiawan

This comment has been minimized.

Copy link

@jeffersonsetiawan jeffersonsetiawan commented Sep 18, 2017

@SteveJobzniak After I update to High Sierra GM candidate, I have issue of missing small icon in the column list view Finder and notification. I think I just miss the small icon thumbnail.

How to fix it? I tried your way, but can't fix this issue.

screen shot 2017-09-18 at 12 07 28

@soleinvisibile

This comment has been minimized.

Copy link

@soleinvisibile soleinvisibile commented Oct 3, 2017

I googled a lot and tried all, I mean A L L the methods above - deleting, Safe Boot, etc - I even switched from Yosemite to El Capitan and now High Sierra, but nothing to do.
Please help me: how do I make THIS icon to appear again on menu bar?
schermata 2017-10-03 alle 08 59 32

@BruceLEO1969

This comment has been minimized.

Copy link

@BruceLEO1969 BruceLEO1969 commented Oct 4, 2017

Cool

@frickenate

This comment has been minimized.

Copy link

@frickenate frickenate commented Oct 18, 2017

ATTENTION TO ALL WHO GET PERMISSION DENIED ERRORS RUNNING THE COMMANDS!

I fixed this issue for myself on 10.13 High Sierra the first time by doing exactly what I describe below. Follow these directions and you should be fixed as well.

With newer versions of macOS, the commands do not work because the files are protected by SIP (System Integrity Protection). This protection means you cannot, even as root user, rm the cache files, or touch /Applications/* and their Info.plist files.

The good news is all you have to do is boot into Recovery Mode! You don't need to disable SIP, as the files involved here can be manipulated in the Terminal directly from Recovery Mode.

Steps:

  1. Boot into Recovery Mode. With machine shut down, power it on and immediately hold down Command+R until the logo appears - or if you have a firmware password, until you are prompted for the password.

  2. Once Recovery is booted, choose the Disk Utility option from the list. If your OSX volume is not already mounted, you need to mount it now. Select the OSX disk; yours might be renamed to something else - but ignore OS X Base System as that is the recovery volume, not your operating system. Click the Mount button in the action bar near the top. If you need to provide a password, I believe it's the account password of any account, or perhaps any Administrator account, or perhaps your firmware password. Whatever the case, one of the passwords you normally use to boot the computer will be the password required here to mount the volume.

  3. Close the Disk Utility app. Now open the Terminal app by going to the Utilities menu and selecting Terminal. It's not in the list of options Recovery offers; you must look in the Utilities menu bar.

  4. IMPORTANT: You are NOT running the exact same commands others have posted!!! /Applications and /Library/Caches while in Recovery Mode point to the base recovery volume you are booted into, not your actual operating system. This is why we needed to mount the OSX volume in Disk Utility in Step 2.

  5. First, get to the root directory of your operating system's volume. By default this will be:

cd /Volumes/OSX

If that produces an error, then your volume name is not the default OSX. You will want to ls /Volumes and look for the name that you changed it to at some point. Important: you do not want OS X Base System! That is the recovery volume, not your operating system. Once you find the name (example: MyMachine), change to that directory with cd "/Volumes/MyMachine" - I included quotes in case your volume name contains spaces.

  1. Make sure you're in the right directory by typing pwd. You should see output like /Volumes/OSX (default) or your custom volume name such as /Volumes/MyMachine.

  2. Now run the following commands.

  • NOTE 1: IF YOU DID NOT FOLLOW STEPS 1 THROUGH 6, THESE COMMANDS WILL NOT WORK! GO BACK AND DO ALL STEPS, YOU CANNOT SKIP ANY!

  • NOTE 2: There is no / prefix at the start of the paths, as you are running these relative to the operating system volume.

  • NOTE 3: Please run one command at a time. Combining into one line makes it too easy to cause errors difficult to diagnose.

  • NOTE 4: No need to use sudo - you are already dropped into root user.

  • NOTE 5: The last command will take a minute or two. I was being paranoid enough to make sure I'm touching every Info.plist, including those in the Utilities/ directory, for apps like Terminal and Activity Monitor.

find private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;
find private/var/folders/ -name com.apple.dock.iconcache -exec rm -rf {} \;
rm -rf Library/Caches/com.apple.iconservices.store
touch Applications/*
find Applications/ -name Info.plist -exec touch {} \;
  1. No need to kill Finder or Dock. You just reboot the system (look in top-left Apple logo icon menu for "Restart").
@star-affinity

This comment has been minimized.

Copy link

@star-affinity star-affinity commented Nov 14, 2017

One year later, but…

@toufikhamdani

Try: touch -f /Applications/Notes.app

or if that doesn't work: sudo touch /Applications/Notes.app

and enter the admin password.

@phoenix-zhu

This comment has been minimized.

Copy link

@phoenix-zhu phoenix-zhu commented Nov 17, 2017

@frickenate's solution(https://gist.github.com/fabiofl/5873100#gistcomment-2232236) works fine for me, all the icons come back. Thanks, man.

@ggmichaelgo

This comment has been minimized.

Copy link

@ggmichaelgo ggmichaelgo commented Nov 22, 2017

This works for me

sudo touch /Applications/*.app; sudo touch /Applications/*.app/Contents/Info.plist; killall Dock

@justingoeres

This comment has been minimized.

Copy link

@justingoeres justingoeres commented Nov 22, 2017

@frickenate's solution above (https://gist.github.com/fabiofl/5873100#gistcomment-2232236) also worked for me, but only for a couple of days :(.

@lwilliamson01

This comment has been minimized.

Copy link

@lwilliamson01 lwilliamson01 commented Nov 25, 2017

@SteveJobzniak, Thank you so much!

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ ( -name com.apple.dock.iconcache -or -name com.apple.iconservices ) -exec rm -rfv {} ; ; sleep 3; killall Dock; killall Finder

@shagamemnon

This comment has been minimized.

Copy link

@shagamemnon shagamemnon commented Dec 1, 2017

New answer that works quick!! From Apple Support:

  1. In Finder > Go to Folder > Enter "Library" > Preferences (see images below if you don't understand this)
  2. Find and remove "com.apple.dock.extra.plist" and "com.apple.dock.plist" then restart.

That's it!

screen shot 2017-11-30 at 4 04 22 pm

screen shot 2017-11-30 at 4 04 40 pm

@MartinsGatavins

This comment has been minimized.

Copy link

@MartinsGatavins MartinsGatavins commented Dec 1, 2017

Actually @frickenate solution was the only one that worked for me with 10.13.1 otherwise OS did not let me to rm or touch files.

@st8800

This comment has been minimized.

Copy link

@st8800 st8800 commented Dec 2, 2017

Man... wasted 1 plus hours of my life trying type all the command lines since the beginning of the thread, which was error proned and didn't work when error free.... while all I had to do was start from the bottom of the thread and follow shagamemnon's solution to delete com.apple.dock.plist and restart. This restored the docked icons. Thanks shagamemnon!

Now to restore the Launchpad icons. Go to terminal and type: rm ~/Library/Application\ Support/Dock/*.db; killall Dock

Presto! All icons restored!

@jdrupal-dev

This comment has been minimized.

Copy link

@jdrupal-dev jdrupal-dev commented Dec 3, 2017

@frickenate solition was the only one working for me too. THANKS

@thundernixon

This comment has been minimized.

Copy link

@thundernixon thundernixon commented Dec 3, 2017

ヽ(´▽`)/

@shagamemnon's solution worked for me! I actually only could find and delete com.apple.dock.plist, but after trashing that and doing a simple restart, my icons are back.

ヽ(´▽`)/

@ruimarinho

This comment has been minimized.

Copy link

@ruimarinho ruimarinho commented Dec 5, 2017

@ggmichaelgo's solution worked for me. Now I just need to fix Month 13 is out of bounds... eating all the CPU 🤦‍♂️

@gordonliu

This comment has been minimized.

Copy link

@gordonliu gordonliu commented Dec 5, 2017

@frickenate your High Sierra solution works for me. Thanks!

@Bradmin82

This comment has been minimized.

Copy link

@Bradmin82 Bradmin82 commented Dec 5, 2017

I'm not sure which solution worked for me, but I thought that none of them were working until I gave my mac a restart. Now the icons are back in the Dock and Launchpad!

@olkeene

This comment has been minimized.

Copy link

@olkeene olkeene commented Dec 6, 2017

@st8800 you made my day, thanks! The solution works on High Sierra 10.13.1

@rio416

This comment has been minimized.

Copy link

@rio416 rio416 commented Dec 7, 2017

@ggmichaelgo 's post worked for me!! I have a 2014 macbook air w/ latest MacOs software FYI and it worked! Thanks! (made an account just to share the news lol)

@eaglejazz

This comment has been minimized.

Copy link

@eaglejazz eaglejazz commented Dec 8, 2017

@frickenate solution was the only one that worked for me with High Sierra [OS did not let me sudo to rm or touch files]... THANKS!

@jaydelrosario

This comment has been minimized.

Copy link

@jaydelrosario jaydelrosario commented Dec 8, 2017

Tried everything - nothing works for me :(

image

@jennopolis

This comment has been minimized.

Copy link

@jennopolis jennopolis commented Dec 9, 2017

Shagamemnon's simple trick worked for me on an iMac running OS 10.13.1! Thank you!

@l-g

This comment has been minimized.

Copy link

@l-g l-g commented Dec 11, 2017

Doesn't @shagamemnon 's solution restore your Dock settings to the default? That is, you have to add/remove what you want in your dock and sort everything again?

@rapkin

This comment has been minimized.

Copy link

@rapkin rapkin commented Dec 12, 2017

@jaydelrosario i had the same issue. But in last update (10.13.2 Dec 12, 2017) this problem fixed.

@Smexhy

This comment has been minimized.

Copy link

@Smexhy Smexhy commented Dec 12, 2017

It's weird that it's happening only when I am playing League of Legends. They were kind of useless at the support ticket though.

@jZipfel

This comment has been minimized.

Copy link

@jZipfel jZipfel commented Dec 15, 2017

I have had this issue since El Capitan, it goes around for a while and then comes back, it's quite annoying... the @frickenate solution works for me in High Sierra but it's not a permanent solution and it's easier to just enter in safe mode (press SHIFT while booting) and then restart than clear all the cached files manually. This are the only two ways that works for me in 10.13.2 MacBook Pro (Retina, 15-inch, Mid 2015). One thing that I noticed is that connecting one or many external monitors, work for a while and then disconnect them seems to trigger the problem almost always.

@liesislukas

This comment has been minimized.

Copy link

@liesislukas liesislukas commented Dec 17, 2017

@st8800 worked well on High Siera 10.13.2 (17C88) but not sure for how long. Thanks

Apple should fix this :\

@xer0x

This comment has been minimized.

Copy link

@xer0x xer0x commented Dec 20, 2017

Thanks @st8800, that was just what I needed to restore my icons.

@lteu

This comment has been minimized.

Copy link

@lteu lteu commented Dec 27, 2017

reply from @shagamemnon +1. Other suggestions are not working for me.

@lysandroc

This comment has been minimized.

Copy link

@lysandroc lysandroc commented Jan 14, 2018

@frickenate thats work for me, thank you!

@rio416

This comment has been minimized.

Copy link

@rio416 rio416 commented Jan 25, 2018

@shagamemnon this solution worked after having this problem again, with a newer laptop. However, only one of things in the preferences was there for me and i restarted and it still worked so dont be alarmed if u only see one of those "com.apple." things

@DonRichards

This comment has been minimized.

Copy link

@DonRichards DonRichards commented Jan 31, 2018

Thanks @frickenate

@Griiid

This comment has been minimized.

Copy link

@Griiid Griiid commented Feb 17, 2018

This works for me: sudo touch /Applications/*.app; sudo touch /Applications/*.app/Contents/Info.plist; killall Dock
macOS High Sierra, MacBook Pro (Retina, 13-inch, early 2015)

@franciscogmm

This comment has been minimized.

Copy link

@franciscogmm franciscogmm commented Feb 26, 2018

@Griiid This didn't work for me. :( High Sierra MacBook Pro (15-inch, 2017)

@goridelta

This comment has been minimized.

Copy link

@goridelta goridelta commented Mar 8, 2018

Thanks @frickenate and @Niresh12495

After your work IMHO is more easy for me in High Sierra 10.3.3 due to SIP:

reboot in single user recovery mode:

Command + R + S

This open directly the recovery terminal without open the GUI that is much more quickly ;-)

in terminal:

csrutil disable

reboot

in Finder open Terminal and:

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder

After some:

/Library/Caches/com.apple.iconservices.store/FAF1E1D8-ADBA-B77E-253D-2897C31FF4D1.isdata
/Library/Caches/com.apple.iconservices.store/1F3D9F08-4C6D-11B7-FF8B-79EAC0B040FD.isdata
/Library/Caches/com.apple.iconservices.store/266D415C-5AA4-8994-E2ED-114D20CB52B4.isdata
...
/Library/Caches/com.apple.iconservices.store/D205AF5B-B969-43A9-580B-8C05E5CEC815.isdata
/Library/Caches/com.apple.iconservices.store/1F8FD1F7-2EA8-4141-F4EC-A5A7B9071CEE.isdata
/Library/Caches/com.apple.iconservices.store/D02EE5D8-1089-8A89-763B-B76B5A02E682.isdata
/Library/Caches/com.apple.iconservices.store
/private/var/folders//b3/q6m4_hbd4sv_24f60z6tfpdr0000gn/C/com.apple.dock.iconcache
/private/var/folders//b3/q6m4_hbd4sv_24f60z6tfpdr0000gn/C/com.apple.iconservices/store.index
/private/var/folders//b3/q6m4_hbd4sv_24f60z6tfpdr0000gn/C/com.apple.iconservices
find: /private/var/folders//b3/q6m4_hbd4sv_24f60z6tfpdr0000gn/C/com.apple.iconservices: No such file or directory
/private/var/folders//zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.iconservices/store.index
/private/var/folders//zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.iconservices
find: /private/var/folders//zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.iconservices: No such file or directory

the Finder reopens with all icons "vaccinated"

If you want to reactivate SIP, the same as the beginning:

reboot in single user recovery mode:

Command + R + S

in terminal:

csrutil enable

reboot

Regards :-)

@iokobi

This comment has been minimized.

Copy link

@iokobi iokobi commented Jul 5, 2018

@zigang93

This comment has been minimized.

Copy link

@zigang93 zigang93 commented Sep 4, 2018

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder

after that restart your mac.

wahlaaah.. all restore and back to normal

@mirkogrewing

This comment has been minimized.

Copy link

@mirkogrewing mirkogrewing commented Oct 11, 2018

On Mojave, by merely removing "com.apple.dock.plist" in /Library/Preferences I got all icons back (they were missing both in dock and Applications folder). I didn't even need to restart.

@foogaz

This comment has been minimized.

Copy link

@foogaz foogaz commented Nov 6, 2018

@zigang93, thanx, its worx (mojave 10.14)

@igrir

This comment has been minimized.

Copy link

@igrir igrir commented Nov 15, 2018

cool trick with touch!

@dahoba

This comment has been minimized.

Copy link

@dahoba dahoba commented Dec 4, 2018

Thank you so much. The @zigang93 's command work for me; on Mojave 10.14.1.

Well, after restart the OS I need to manage icons on the Dock again, all reset.

@peterbuga

This comment has been minimized.

Copy link

@peterbuga peterbuga commented Dec 30, 2018

this fixes the generic icons displayed in launchpad & dock

sudo find /Applications -type f -name 'Info.plist' -maxdepth 4 -exec touch {} +
killall Finder
killall Dock

hope it helps someone

@Palme2

This comment has been minimized.

Copy link

@Palme2 Palme2 commented Mar 16, 2019

@scherii This worked for me on Yosemite DP3!
It's what I needed to do after replacing folder icons with LiteIcon.

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;
sudo mv /Library/Caches/com.apple.iconservices.store com.apple.ic

Just being careful on the last one (renaming instead of removing)

it calls "Operation not permitted"

@Palme2

This comment has been minimized.

Copy link

@Palme2 Palme2 commented Mar 16, 2019

this fixes the generic icons displayed in launchpad & dock

sudo find /Applications -type f -name 'Info.plist' -maxdepth 4 -exec touch {} +
killall Finder
killall Dock

hope it helps someone

its the same - "Operation not permitted"

@Palme2

This comment has been minimized.

Copy link

@Palme2 Palme2 commented Mar 16, 2019

Its just a problem with the generic icon for all folders ,they looks like a empty white icon - the others are ok

@Palme2

This comment has been minimized.

Copy link

@Palme2 Palme2 commented Mar 16, 2019

i will try restart my computer from 2nd HDD, maybe I don't have this problems with permission

@om2c0de

This comment has been minimized.

Copy link

@om2c0de om2c0de commented Jul 6, 2019

@zigang93, Thanks, it works great on Mojave 10.14.5 !!!

@demartini

This comment has been minimized.

Copy link

@demartini demartini commented Aug 20, 2019

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder

after that restart your mac.

wahlaaah.. all restore and back to normal

It worked perfectly, thanks.

@smoothdvd

This comment has been minimized.

Copy link

@smoothdvd smoothdvd commented Sep 7, 2019

sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
after that restart your mac.
wahlaaah.. all restore and back to normal

It worked perfectly, thanks.

Thanks all! Save my life on macOS Catalina

@realityworks

This comment has been minimized.

Copy link

@realityworks realityworks commented Sep 25, 2019

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} ;
sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} ;

These two steps along with deleting the /Library/cache folder fixed all icon issues.
Thank you! @inket

Icons were missing in strange places, and even missing icons when dragged where fine during dragging but when placed the image was incorrect.

@userlvqingke

This comment has been minimized.

Copy link

@userlvqingke userlvqingke commented Oct 11, 2019

@jasonm23 Nice!

@moritzz

This comment has been minimized.

Copy link

@moritzz moritzz commented Apr 22, 2020

Thanks @smoothdvd .

@afnizarnur

This comment has been minimized.

Copy link

@afnizarnur afnizarnur commented Jun 8, 2020

It works perfectly! Thanks @zigang93

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 26, 2020

I've wanted to change an app icon programmatically, but nothing mentioned here worked for me. So I've tried to replicate what Finder is doing when you drag a new icon via Get Info pane. Turns out it creates a file Icon\r inside the app bundle and sets a special binary attribute for it, which you can see using xattr:

> xattr -lx /Applications/App.app
com.apple.FinderInfo:
00000000  00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020

So, first I've dragged the icon manually to create Icon\r file (it appears to contain the dragged icon data, but differently encoded, if someone knows, what binary representation it is, please share). After that, you just save Icon\r file, the value for the com.apple.FinderInfo attribute and boom (this even works for ordinary folders, it doesn't need to be an app).

In fish:

cp ~/Documents/MyAwesomeIcons/IconForTheApp /Applications/App.app/Icon\r
xattr -wx com.apple.FinderInfo "0000000000000000040000000000000000000000000000000000000000000000" /Applications/App.app

In Bash/Zsh (thanks @jasonm23):

icon_name=$(echo -ne "Icon\r")
cp ~/Documents/MyAwesomeIcons/IconForTheApp "/Applications/App.app/$icon_name"
xattr -wx com.apple.FinderInfo "0000000000000000040000000000000000000000000000000000000000000000" /Applications/App.app

No cache invalidation needed and it works every time.

P.S. If you already changed the icon and want to change it again to a different one, it seems, you need to remove both the attribute and Icon\r file first.

In fish:

xattr -d com.apple.FinderInfo /Applications/App.app
rm /Applications/App.app/Icon\r
cp ~/Documents/MyAwesomeIcons/AnotherIconForTheApp /Applications/App.app/Icon\r
xattr -wx com.apple.FinderInfo "0000000000000000040000000000000000000000000000000000000000000000" /Applications/App.app

In Bash/Zsh (thanks @jasonm23):

icon_name=$(echo -ne "Icon\r")
xattr -d com.apple.FinderInfo /Applications/App.app
rm "/Applications/App.app/$icon_name"
cp ~/Documents/MyAwesomeIcons/AnotherIconForTheApp "/Applications/App.app/$icon_name"
xattr -wx com.apple.FinderInfo "0000000000000000040000000000000000000000000000000000000000000000" /Applications/App.app
@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

@andreiborisov - that's interesting. However you can reliably do this programatically by just doing.

EDIT:! fix icon destination...

cp ~/Documents/MyAwesomeIcons/AnotherIconForTheApp /Applications/App.app/Contents/Resources/App.icns
touch /Applications/App.app
@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

BTW beware of those \r littered in your comment, dozens may not know they are just CRs

NOTED: Special filename created by Get Info icon drag.

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

@jasonm32

However you can reliably do this programatically by just doing.

cp ~/Documents/MyAwesomeIcons/AnotherIconForTheApp /Applications/App.app/Icon
touch /Applications/App.app

I've tried touch in combination with swapping an app .icns file inside the bundle first, but it doesn't work for me (maybe after cache clearing it will work, but I don't want to tinker with the cache).

BTW beware of those \r littered in your comment, dozens may not know they are just CRs

In this case, it's part of the file name, it should be Icon\r (with a carriage return), otherwise, it won't work.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

In this case, it's part of the file name, it should be Icon\r (with carriage return), otherwise, it won't work.

Ok.... TBH I missed the whole "simulate Get Info / drag/paste icon" thing.

Why not just copy the AppName.icns into /Applications/AppName/Content/Resources/AppName.icns and touch /Applications/AppName.app

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

If you can, please record a screen cap of the process so I can see it fail.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

Tried this again just now, and it's (copy icon to bundle & touch /Application/App.app for context) failing for me too. to be continued...

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

Ok so for me the cp / touch method fails only happens on specific app bundles. (1 of 3 so far tested...)

However for that one failing bundle, xattr -wx method also fails, but I think that's mainly the exotic filename that Macos adds on if we really drag it there.

For example

ls /Applications/Foo.app/Icon\r
ls: /Applications/Foo.app/Iconr: No such file or directory

Also I think this may be relevant: (post drag n drop method)

ls -l /Applications/Foo.app
total 1240
drwxr-xr-x  9 jason  admin  288 Aug 25 09:57 Contents
-rw-r--r--@ 1 jason  admin    0 Aug 27 09:38 Icon?

Filesize is zero on Icon?


So if I tab complete the filename in zsh I get:

/Applications/Foo.app/Icon$'\r'

Although also trying:

cp AppIcon.icns /Applications/Foo.app/Icon$'\r'
xattr -wx com.apple.FinderInfo "0000000000000000040000000000000000000000000000000000000000000000" /Applications/Foo.app

Also fails...

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

A straight copy of an .icns to Icon\r ends up with this BTW.

ls -l /Applications/Foo.app
total 680
drwxr-xr-x  9 jason  admin     288 Aug 25 09:57 Contents
-rw-r--r--  1 jason  admin  344212 Aug 27 09:52 Icon?

Edit: to note the filesize

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

However for that one failing bundle, xattr -wx method also fails, but I think that's mainly the exotic filename that Macos adds on if we really drag it there.

Yeah, it seems to have such a weird name to avoid potential name conflicts with user files.

I can confirm it doesn't work in Zsh and Bash (I’m using fish so I didn’t catch it). I’m not Zsh expert, but there definitely should be a way to enter \r literally in a command-line.

UPDATED

This is works:

icon_name=$(echo -ne "Icon\r")
cp ~/Documents/MyAwesomeIcons/AnotherIconForTheApp "/Applications/App.app/$icon_name"

I've updated the original post to reflect this.

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

A straight copy of an .icns to Icon\r ends up with this BTW.

It should have non-zero file size, however, it appears to be converted in some unknown binary format by Finder, since the file size is different from dragged .icns file.

Filesize is zero on Icon?

Possible conversion fail resulted in zero file size Icon\r? Does the icon change for the app after the dragging that produces zero file size Icon\r?

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

At zero bytes it's like some weird flag.

I mean if you are getting this to work, and repeatably, good for you.

TBH though it doesn't look like a good option. I am surprised that you are having issues with the touch method. Are you on Catalina btw?

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

Are you on Catalina btw?

Yep.

In my opinion it’s much better solution, because:

  • it works both for apps and folders
  • it doesn’t require to change anything in the app bundle which can have unintended consequences with Gatekeeper and other integrity checks
  • you can easily revert changes even with Finder GUI
@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

The part about "it works on my machine" was missing.

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

The part about "it works on my machine" was missing.

😂 I guess, but there is nothing special about my machine. Have you tried my updated snippets for Zsh?

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

Seems like the zero bytes Icon? is more than just filename change for the .icns file though.

To me that's a thing we should know if we're going to say this is a working / repeatable solution.

If we got that, I'd say it's at least an ok solution.

BTW wrt folders, is that what happens there too? An Icon? file is placed inside the folder and the xattrs are patched in the same way?

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

Oh I didn't see your naming update.

So yeah, naming is one part but clearly Macos is not copying the icns to the Icon? file.

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

So yeah, naming is one part but clearly Macos is not copying the icns to the Icon? file.

No, the resulted file is actually bigger in size compared to .icns, so it’s definitely in a different format. As far as I know those Icon\r files are date back to the oldest macOS releases, so surely someone figured out how they encoded by now.

For our purposes, however, it's not strictly necessary to know what format it is. I’ve just pre-converted icons that I need by dragging them and copy already encoded versions. Would be nice to be able to skip this step though, yeah.

BTW wrt folders, is that what happens there too? An Icon? file is placed inside the folder and the xattrs are patched in the same way?

I’m not familiar with wrt folders. But it’s the same with ordinary folders, makes no difference whether it’s an app bundle or a folder for macOS whatsoever.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

Ah sorry.

WRT = with regard to

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

it's not strictly necessary to know what format it is. I’ve just pre-converted icons that I need by dragging them and copy already encoded versions. Would be nice to be able to skip this step though, yeah.

Ok so I missed the part where you can't use a icns file. TBH that pretty much defeats the purpose.

However If you can automate away that step maybe you have a workable solution.

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

Ok so I missed the part where you can't use a icns file. TBH that pretty much defeats the purpose.

Yeah, I guess I should've mentioned that I'm doing this to switch between dark/light variants of the app icon.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

I better test to see if the touch method is still working in Catalina! but I hope you figure out why it's broken for you. Please do test more app bundles (if you haven't) because there do seem to be some challenging ones.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

FYI tested touch method in Catalina. (only one bundle tested, but working ok)

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

(The app bundle that failed on Mojave for me, still fails on Catalina. No big shock there.)

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

(The app bundle that failed on Mojave for me, still fails on Catalina. No big shock there.)

Interesting...

However If you can automate away that step maybe you have a workable solution.

I'll try to investigate how Icon\r encoded, but knowing macOS it's probably some arbitrary binary nonsense😁

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

So are you also seeing these Icon\r files as zero bytes after dragging? Because that's not really signalling encoding is it?

It signals some undocumented black magic voodoo. That's why I'm basically 100% out on this method.

But good luck!

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

So are you also seeing these Icon\r files as zero bytes after dragging?

No, they have non-zero size for me. Does an icon for the app changes with the dragging method for you when the size of Icon\r is zero?

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

It signals some undocumented black magic voodoo. That's why I'm basically 100% out on this method.

I mean it is all undocumented black magic, unfortunately. Why touching an app bundle refreshes cache for example? Why it works for one app, but not for the other? More importantly, how can we sure it won’t break in the next macOS release? At least with Icon\r method there is some level of confidence it won’t change the behavior between macOS versions simply because it’s part of the filesystem and it’s required to be backwards compatible.

But I see your point of course.

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

So are you also seeing these Icon\r files as zero bytes after dragging?

No, they have non-zero size for me. Does an icon for the app changes with the dragging method for you when the size of Icon\r is zero?

That's right, but I'm several hours away from the last live test. It's something I can check again in the morning.

@andreiborisov

This comment has been minimized.

Copy link

@andreiborisov andreiborisov commented Aug 27, 2020

Ok, that's even more interesting😂

CleanShot 2020-08-27 at 19 08 35@2x

yet

CleanShot 2020-08-27 at 19 09 00@2x

Sorry, I didn't try to check the size from shell before, I have no idea why it's reported as 0 there, but in reality, it has size as you can see...

@jasonm23

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Aug 27, 2020

"in reality..." Uhmmm.

Tbh in reality all we know is that Finder's internal logic has embedded the icon somewhere. The trouble is, where. We know it's not really in that file Icon\r because the actual file system doesn't register the file size.

The worst problem here is that neither representation is "in reality". They're both views through different abstraction layers, but it's safe to say only that those icon data bytes went "somewhere". Unfortunately that doesn't give us a thing to stand on.

All completely undocumented. All completely unreliable.

If you can script it somehow and make it reliable, applause for you.

@frakman1

This comment has been minimized.

Copy link

@frakman1 frakman1 commented Dec 1, 2020

On High Sierra, deleting com.apple.dock.plist worked for me. However, a couple of native apps stubbornly refused to work. The Notes and Screen Sharing apps still have the default app icon.

Update:
I fixed those apps by removing them from the dock and then re-adding them. It worked after that.

@beginnerJq

This comment has been minimized.

Copy link

@beginnerJq beginnerJq commented Apr 2, 2021

@jasonm23 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment