title: How to remove an application Icon from Dock from Mac OSX Mavericks?
body: <p>I am writing an application uninstaller in which I want to remove the icon of our app from Dock. During instalation the icon was added to dock using the following on commandline:</p>
  
  <pre><code>sudo -u "$USER" defaults write com.apple.dock persistent-apps -array-add "&lt;dict&gt;&lt;key&gt;tile-data&lt;/key&gt;&lt;dict&gt;&lt;key&gt;file-data&lt;/key&gt;&lt;dict&gt;&lt;key&gt;_CFURLString&lt;/key&gt;&lt;string&gt;/Applications/MyApplication.app&lt;/string&gt;&lt;key&gt;_CFURLStringType&lt;/key&gt;&lt;integer&gt;0&lt;/integer&gt;&lt;/dict&gt;&lt;/dict&gt;&lt;/dict&gt;"
  sudo -u "$USER" osascript -e 'tell Application "Dock"' -e 'quit' -e 'end tell'
  </code></pre>
  
  <p>During uninstallation I am using the following shell script to remove icon from Dock:</p>
  
  <pre><code>#!/bin/sh
  # Get location of entry for our application in Dock
  dloc=$(defaults read com.apple.dock persistent-apps | grep file-label\" | awk '/MyApplication/ {print NR}')
  dloc=$((dloc - 1))
  
  # Remove this entry from Dock's plist file : com.apple.dock.plist
  /usr/libexec/PlistBuddy -c "Delete persistent-apps:$dloc" ~/Library/Preferences/com.apple.dock.plist
  
  # Restart Dock to persist changes
  osascript -e 'delay 3' -e 'tell Application "Dock"' -e 'quit' -e 'end tell' -e 'delay 3'
  #killall Dock
  </code></pre>
  
  <p>I can see that the above script successfully removes the entry of MyApplication from the persistent-apps from com.apple.dock.plist plist. However after restarting the Dock, the dock still has the same icons as the previous.</p>
  
  <p>Can someone please help?</p>
  
  <p>Thanks,</p>