t_spoon wrote:
I'm aware of dockutil, which is great, but would involve installing it on a hundred users systems, I'd like to avoid that kind of dependency.
It might also be a way to give you the commands necessary to easily accomplish this task, or failing that, demonstrate that it can't be done reliably.
I had already seen the linked StackOverflow page, but that's about adding items to the Dock, which I can already do. Putting the correct version of the app in the dock is no problem, it's getting the old one out that's a problem.
Indeed. That's why I said that above. There are a couple of different ways to solve this. You can extract the entire array of elements, locate just the one you want to remove, remove it, and then replace the array. You can also find the numeric index of the element you are searching for and attempt to remove just that one. But that might also ultimately require replacing the entire array.
I develop for prepress art. Most of our code base is Applescript... all the apps that I'm deploying here that I need to add/remove from the dock are Applescript. So I don't think I need to avoid it here.
The procedure for removing an element from an array is rather complicated and AppleScript is rather fragile. Plus, I don't even know if AppleScript has a native interface to the defaults system. That previous example you were using was hacking up a plist persistence file from preferences, which wasn't reliable then and definitely isn't today. So you might have to code the AppleScript to do all of this array manipulation via "do shell script". That'll keep you busy. Just don't forget to "killall cfprefsd".
The different versions of the apps are code signed and have unique bundle ID's. This situation happens all the time - for example, many users install multiple versions of Adobe Apps
You had me, or rather, lost me, at "Adobe apps". I've had a number of "discussions" with people regarding various problems with Adobe apps. I've had Senior Adobe Scientists tell me that things I demonstrated in a few minutes are, in fact, impossible. I re-packaged that into an App Store utility to do the impossible.
But I digress. Unique, version-specific bundle IDs are unusual. I'm not disputing you if you say Adobe does that. I'm just glad I don't use Adobe products if that's true. But if your apps are using version-specific bundle IDs, then that would avoid many of the problems I was referring to.
If you look at the dock plist I'm trying to modify here, it keeps track of the app the dock button connects to by its path. Not bundle ID or application name, or anything else that can get confused between versions.
The whole problem with hacking around on some other app's internal data is that those are implementation details. Just because Apple persists the value as a path that you can see doesn't mean that Apple will continue to do that in the future. It doesn't even mean that the Dock uses those paths internally. Apple really prefers to use bundle IDs for launching apps.
We do use git to store different versions of the code. GIT is not a deployment mechanism. You don't put your end users on git and deploy applications to git repositories, git is for managing code.
You can use git for whatever you want.
OK, so most major developers, like Adobe, Microsoft, and of course Apple are doing it wrong, because many of their apps add themselves as persistent to the dock when installed.
No. You simply cited two specific developers who are notorious for ignoring standard conventions (as well as published Apple APIs) and doing it their own way.
You can't count Apple. The Dock is Apple's software. Therefore, Apple can do anything it wants with the Dock. The fact that Apple hasn't published any kind of API for the Dock means that Apple does not support any kind of external manipulation. Apple even makes a point to forbid this behaviour in its Mac App Store Review Guidelines.
But maybe removing old versions isn't standard. Unless they're uninstalled, but I assume that's MacOS, not the installer, automatically removing things that are no longer present.
There is no automatic uninstallation mechanism. There is no uninstallation mechanism of any kind.
I'll keep looking.
I strongly suggest you review what your high-level goals are. What are you trying to accomplish? It is not unusual for people to become fixated on some dead-end path like this and refuse to consider the many, many great alternatives that exist. It is difficult to me list them because they are practically infinite.
If this whole problem is because of old references in the Dock, then use MDM to forbid users from adding their own references. Or maybe pre-populate the Dock with dynamic references that automatically resolve to the previously specified version environment. But if you are determined to only consider one of the few paths that Apple explicitly doesn't support and actively discourages, then your experience is going to be sub-optimal.