See https://developer.apple.com/library/mac/releasenotes/DataManagement/RN-CoreFoundationOlderNotes/
and especially the section on CFPreferences Plist Files. cfprefsd's caching is even more aggressive in Mavericks than it was in Mountain Lion. The upshot is that Mac admins need to stop directly modifying, removing, or replacing preference files.
I will second @gregneagle on how aggressive cfprefsd is at caching on Mavericks. Even my friend PlistBuddy can't save me from it's clutches. Defaults write will still work with this preference caching, but tends to get a bit ugly with complex changes.
@gregneagle][/url @freddie.cox][/url
Thanks for the responses! My progress and comments:
I agree that editing the source plists are not ideal, but it was the only way I was able to get it working without writing a lot of C code.
cfprefsd is the reason the preferences stay even after the plists are deleted. It is caching a copy into memory and is written back even after deleting the plists. A reboot between changes will pull the new configuration.
While I am using 'defaults' for writing to the file, I am not sure if its the proper form, or how Apple is expecting me to. I basically just add the item to the dock on a test computer and then grab the objects that it wrote into one big string for dropping into a bash script. I was able to get this working (see below). I run a script like it at first boot via Casper Imaging so that all future users get the same dock.
#!/bin/sh
#empty the dock of apps
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array
#empty the dock of other items
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-others -array
#remove the extra junk that apple adds
rm /Library/Preferences/com.apple.dockfixup.plist
#the first app must have an extra key on it
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Launchpad.app</string><key>_CFURLStringType</key><integer>0</integer></dict><key>file-type</key><integer>169</integer></dict></dict>"
#all following apps can follow the same pattern
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Safari.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Mail.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
#put the dock permissions back to their default
chmod 744 /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist
exit 0
Note that the first app in the list has an extra key and integer added onto it.
<key>file-type</key><integer>169</integer>
With 10.8 I had those extra objects on a few of my apps and it still worked, but Mavericks needs it formatted particularly, and so it ignored the whole file.
Thanks for the help on this. Once I got how to update the dock plist, I was able to do incremental testing and solve it.