I received a report that after installing HsoiContextualServices 3.1, the Services did not show up in the Services menu.
Eh? I tested that and it worked for me in the numerous times I ran through everything. But I know and trust the bug reporter, so I investigated further. Sure enough, I could get it such that sometimes it didn’t work. The installer has a postflight script that runs a tool I created that simply calls
NSUpdateDynamicServices(), and I swore that was working. But upon a careful re-read of the documentation, that seems to only apply for dynamic Services offered as .services bundles in the ‘Library/Services’ folder. But I can’t believe that to be true because I certainly noticed I could delete all copies of HsoiContextualServices.app from my system yet those Services still appeared in the menu (tho selecting them would cause an error since the app was nowhere to be found). Run my little UpdateDynamicServices tool and they would no longer appear. Or during my development work, I could change something in the application, run the tool, and things got picked up. So I wear it picks up applications too.
Now there is one thing Apple tells us developers we can do, but it’s technically unsupported and could change and/or be removed from the system at any time. We can run the ‘/System/Library/CoreServices/pbs’ tool and it will cause a rebuild of the Services. That does seem to be pretty reliable, but of course it’s not for general use and we shouldn’t count on it.
So how the OS picks up Services offered by applications? I guess upon copy, install, or other Launch Services voodoo. But in the end it’s just that, voodoo. Most of the time it works, gets picked up, rebuilds, and life goes on. But sometimes it doesn’t… apparently.
This is annoying.
The only way I could make a reliable user experience would probably be to have the installer do some further manipulations, such as launching and quitting the HsoiContextualServices.app, or perhaps forcing the user to log out. I hate forcing the user to log out, and I actually would prefer to not even use the installer at all except there’s some fiddling and cleanup work that has to be done… tho apparently that isn’t working 100%. Launch and quit… that doesn’t appeal to me, but I guess it may be a solution. The trouble is, if the user doesn’t install the application in the ‘/Applications’ folder, I’d have to do a search for the application, which would greatly lengthen the install process. That’s not ideal. I could be naughty and invoke the ‘pbs’ tool, but that’s naughty.
So there’s really no ideal solution to this.