So I found a command that lets me create Dock entries via Terminal. This was working fine on OS X El Capitan, but not with macOS Sierra.

Any ideas how this can be done with macOS Sierra?

This is sample command that works with OS X El Capitan:

defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/VLC.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"

As a test in macOS Sierra, I just downloaded the vlc-2.2.4.dmg file and installed VLC to /Applications via drag and drop to the Applications alias within the installer window.

In Terminal, I ran the following command:

defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/VLC.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"; killall Dock

Note that I added ; killall Dock directly after the command line from your question.

As the Dock reappeared, the VLC Dock Tile was present and I then click it. VLC opened as expected.

  • somehow when I tried it, it wasn't working – mrjayviper Oct 3 '16 at 23:22
  • @mrjayviper, had you used killall Dock directly afterward the first time? If not, that is why is didn't work. When modifying com.apple.dock you have to used killall Dock directly afterward, either with a ; when done in the same command line or without it directly after. – user3439894 Oct 4 '16 at 1:30
  • I didn't use killall immediately. But at the end of my script is a killall Dock. – mrjayviper Oct 4 '16 at 11:05
  • 1
    @mrjayviper, As many of the preferences are loaded to memory at login, then when making a change with defaults in this case you need to use killall Dock directly after as the system can/will make a changes to the copy in memory and write it back to disk file and thus overwrite what you changed as it was never memory resident. That is possibly/probably what happened to you. – user3439894 Oct 4 '16 at 11:21
  • @user3439894 I had the same situation, and this code works when run from the terminal. However, do you see any reason why it would not run from within a post-installation script in an Installer? – Max Wyss Dec 10 '17 at 20:07

You must log in to answer this question.

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